input_devices

To build on the output devices week, I am going to use a joystick. Using a joystick was new and I wasnt sure of the output so I used a simple code to measure the output in the serial moniter. I used this tutorial:

Once I new the range of analog values I would recieve and what I would get at each joystick position I could begin to figure out the code to control the motors and the math to relate the joystick output to motors speed. This cooincided at a time when my computer had been fried during the Machine Building assignment, so I used a very analog process to understand this very analog output.

programming programming programming programming

It was unusual writing code like this. Especially when I only had a basic grasp of the structure of Arduino code. It was quite nice to get to oldskool pen and paper and I think it helped in working out the maths.

programming

I am really enjoying using Fritzing to put together circuits and map them for my breadboard experiments. It is a very clear and visual interface. I haven't pushed its limits, but for this process it is fantastic.

I got all wired up, using four LEDs to indicate the left and right motor and their direction. My first iteration of code unfortunately did not work. Even after recieving some help on the structure of 'IF' statements and analog/digital output. I eventually found out that my issue was with how arduino works out its mathematics. I was using integer maths and my calculations were always being 'truncated' to zero which meant my robot was going nowhere. After some online forum help I used 'float' maths that simply meant I had to add a '.0' to some of my numbers. I researched this further and ideally 'float' maths should be avoided as it takes much longer, but for my simple sums the delay is unnoticable. I need to continue to research, but it can be avoided by using large numbers and being happy with approximations.

After this success, I am experimenting with using an NRF24L01 radio transceiver to make the robot remote control. I will be using this tutoial. I also need to start considering the design of the robot and how to power the motors (The require more power than the Arduino can provide).

Week 15 is also where I am putting together the board for all output/input and networking weeks