I’m doing a simple project just to get a better understanding of coding. I’m looking to connect four momentary pushbuttons (numbered 1 through 4) and have a Green LED light up if they are pushed in a certain order.
I want it to have several “passwords” that work for it, such as “1 2 3 4” and “1 3 2 2”.
I currently have the following code ready:
int ledPin = D0;
int buttonPin1 = D1;
int buttonPin2 = D2;
int buttonPin3 = D3;
int buttonPin4 = D4;
void setup()
{
pinMode( buttonPin1 , INPUT_PULLUP);
pinMode( buttonPin2 , INPUT_PULLUP);
pinMode( buttonPin3 , INPUT_PULLUP);
pinMode( buttonPin4 , INPUT_PULLUP);
pinMode( ledPin , OUTPUT);
}
void loop()
{
int buttonState1 = digitalRead( buttonPin1 );
int buttonState2 = digitalRead( buttonPin2 );
int buttonState3 = digitalRead( buttonPin3 );
int buttonState4 = digitalRead( buttonPin4 );
but I’m not sure what to put next in the loop in order to facilitate the input of the passwords.
But I’m having trouble with the serial monitor. My COM port isn’t showing up at all, it’s only showing my bluetooth input. I have the Spark plugged into my USB port, and I’m running CoolTerm for the monitoring, but no dice. Do you know what might be causing this?
I’m using a Mac, not sure if that makes any difference.
Got it, thanks! It worked once, but then when I tried a second time, it has stopped working. It’s “blinking blue” but now it’s not showing up in the Port options again. I’ve tried unplugging it and restarting, as well as moving it to other USB ports, but no dice.
And that's it, even though my spark is plugged in and blinking blue. It's perplexing. I've tried restarting my computer as well as unplugging and re-plugging the spark.
That’s really strange… I was about to reply with pretty much the same thing @BulldogLowell said about screen which is my preferred serial terminal now… however the Core that I just grabbed won’t open up a Serial port for the life of me. I put my Core in listening mode and nothing shows up for ls /dev/tty.* I grabbed another Core though and it works fine. I think I’ll do some reprogramming of this one that doesn’t work and see what it takes to make it work.
EDIT: Just put Tinker back on my non-working Core with Spark CLI command spark flash --usb tinker with Core in DFU mode… and it’s opening up a serial port now. Not sure what I had programmed on it… but that was the issue. Factory Reset sounds like a great idea for you @skrotseng