From the course: Learning Arduino: Interfacing with Analog Devices
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Coding for the joystick and LEDs - Arduino Tutorial
From the course: Learning Arduino: Interfacing with Analog Devices
Coding for the joystick and LEDs
- [Instructor] To do the coding for this project, I provided a starter file. So why don't you go ahead and open the starter file for joystick and LEDs, and then I'll walk you through the coding. So for lines six all the way to line 10, I identify the pins that I'm connecting the ones from the joystick, for the x-axis, y-axis, and for the z-axis. I also initialize some variables that are going to store the values that we read from the analog pins into them. For lines from number 12 all the way to number 17, I identify the pins that I'm connecting the LEDs to. As with lesson variables, we are going to store the new mapped values for each of the LEDs. In the void setup, this is the pin mode for the z-axis, as well as for the three LEDs, and initializing the Serial.begin. In the void loop, we are going to do the programming here. So the very first thing we are going to do is to read from the analog pin, and save it into a variable. So x-value equals, since we're reading from the joystick,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Using the joystick to control LEDs51s
-
(Locked)
Wiring up the joystick and LEDs32s
-
(Locked)
Coding for the joystick and LEDs6m 17s
-
(Locked)
Using an LDR sensor to control a motor21s
-
(Locked)
Wiring41s
-
(Locked)
Coding the LDR and sensor4m 9s
-
(Locked)
Using a joystick to control a motor49s
-
(Locked)
Wiring up the joystick and motor37s
-
(Locked)
Coding the joystick and motor5m 48s
-
(Locked)
-