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 the joystick circuit

Coding the joystick circuit - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Analog Devices

Start my 1-month free trial

Coding the joystick circuit

- Alright! So for the coding for the joystick, we are going to program a very simple code that shows the values that we read from each access. So, the very first thing again, we need to initialize what each pin is connected to. So integer xPin is connected to A0. (typing on computer) Integer yPin is connected to analog input one, and then, finally, the z axis. I'm going to just put it as a KeyPin that's connected to digital Pin eight. Alright. So now in the void setup I'm going to use the internal pull up resistor for the KeyPin which is, um, z axis. So, pinMode, and then the KeyPin (typing on computer) and then I'm going to use initialize it is an input and then activate the pull up resistor. (typing on computer) Okay. And then for the KeyPin, uh, since it's a switch it's either on and off, so I'm just going to write it as a high as a default and whenever I press on it, it changes to zero. So I'm just going to write digitalWrite KeyPin (typing on computer) and then it only shows it…

Contents