In this video, Zahraa demonstrates how to use the digitalRead() function when coding a pushbutton and using serial monitor.
- [Narrator] Alright, so for coding…the push button I'm going to go ahead…and open one the examples provided by…the Arduino library.…So go ahead and go to File > Examples,…and then select Basics,…and finally DigitalReadSerial.…So this is the code for Pushbutton.…So I'm going to go ahead and save it as another file…because I'm going to make some changes.…So File > Save As, and then I'll just add…pin 12 to it, and then save it.…
So the code, it covers most of things…we've already went through before…so on line number 12 you can see…that there's integer pushButton…that's connected to pin two.…So we need to modify that to pin 12…which is according to our wiring connection.…Then in the void setup which is line 15 all the way…to line 20 we have a Serial.begin initializing…the communication between the Arduino board…and the computer.…And the pin mode for the push button that's connected…to pin 12 is input.…
Now in the void loop function in line 25…this is the only command or function…that we've never covered before.…So now in order to read an input from Arduino…
- What's an Arduino?
- Creating an Arduino program
- Using the setup() and loop() functions
- Using the pinMode() and digitalWrite() commands
- Creating your first sketch
- Writing code to turn LEDs on and off
- Wiring a pushbutton to Arduino
- Activating an LED with a pushbutton
Skill Level Beginner
Learning Arduino: Pulse Width Modulationwith Rae Hoyt1h 16m Intermediate
Learning Arduino: Interfacing with Hardwarewith Zahraa Khalil1h 40m Intermediate
1. Introduction to Arduino
2. Creating an Arduino Program
3. Interface with Ouptut: LED
4. Interface with Input: Pushbutton
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.