• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

blink and button

Q&A Forum › Category: ESP32 › blink and button
0 Vote Up Vote Down
docweide asked 7 years ago

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
0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Are you using an external LED? Can you post the code that you’ve uploaded?
Thanks!

0 Vote Up Vote Down
docweide answered 7 years ago
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);
 
}
}
0 Vote Up Vote Down
docweide answered 7 years ago

Here is a link to the picture
https://imgur.com/a/J1WXWdA

0 Vote Up Vote Down
docweide answered 7 years ago

I found the problem. I had the legs to the LED backwards.

0 Vote Up Vote Down
Rui Santos Staff answered 6 years ago

I’m glad it’s working now! Thanks for letting me know and sorry that I couldn’t help much!

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.