From the course: Learning Arduino: Interfacing with Analog Devices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Coding for the joystick and LEDs

Coding for the joystick and LEDs - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Analog Devices

Start my 1-month free trial

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,…

Contents