I purchased your course and tried the blink example. Blink worked but when I changed the values for low and high they seemed to be backwards. High I coded at 2000 and low at 500 and the light stayed on for a half second and off for 2 sec.
I also just tried the button example and it does’t work at all. However, the board light stays on constantly.
My board is a nodemcu but their documentation states to use esp32 dev module. Would that be why I am getting different results?
5 Answers
Are you using an external LED? Can you post the code that you’ve uploaded?
Thanks!
Yes I am using an external LED. The code is the same as in the example. This is the code.
// set pin numbers
const int buttonPin = 4; // the number of the pushbutton pin
const int ledPin = 16; // the number of the LED pin
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
Serial.begin(115200);
// initialize the pushbutton pin as an input
pinMode(buttonPin, INPUT);
// initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(buttonPin);
Serial.println(buttonState);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH
if (buttonState == HIGH) {
// turn LED on
digitalWrite(ledPin, HIGH);
} else {
// turn LED off
digitalWrite(ledPin, LOW);
}
}