Converting C++ to MicroPython for a Raspberry Pico Project
Posted: Thu Mar 11, 2021 7:13 pm
Greetings all,
I have a working C++ Script. I'm not 100% fluent with Python yet so I'm hoping someone could take pity on me and help.
This is the working C++ Script.
My 2 questions.
How would I initialize the boolean string for NAV_ledState?
Is the if statement syntax similar and how would one toggle the LED other than digital write?
I have a working C++ Script. I'm not 100% fluent with Python yet so I'm hoping someone could take pity on me and help.
This is the working C++ Script.
Code: Select all
// NAV - Navitgation Light Prefix
#define NAV_LED_PIN 2
// Navigation Lights
#define NAV_LED_ON 150
#define NAV_LED_OFF 1000
unsigned long NAV_msLast; // last time the LED changed state
boolean NAV_ledState; // current LED state
pinMode(NAV_LED_PIN, OUTPUT);
LOOP:
// Normal Stuff
now = millis();
// Navigation Lights
if (now - NAV_msLast > (NAV_ledState ? NAV_LED_ON : NAV_LED_OFF)) {
digitalWrite(NAV_LED_PIN, NAV_ledState = !NAV_ledState);
NAV_msLast = now;
How would I initialize the boolean string for NAV_ledState?
Is the if statement syntax similar and how would one toggle the LED other than digital write?