This week I re-did a few of the labs to practice setting up the board and coding. In trying to practice using variable resistors, I had some issues when I tried to include two photo sensors and two LEDs.
Below you can see that only the green LED is on when I plug in the Arduino. This was my first issue. I couldn’t figure out why the red light wasn’t turning on. I ended up trying out a few different LEDs and it still didn’t come on.
The other issue was related to my code. I used the map function to change the range of photo sensor so it could communicate to the LED output. But when I printed the values of the green LED it was still showing 400-900, instead of 0 to 255. This could be related to having issues understanding the map function, or if something is wrong with my wiring.
Servo Motor Lab
After trying out the Analog Output lab with tones (see previous post), I tried the Servo Motor lab.
It took me a few tries to understand where the analog input, power, and ground went in relation to the motor. It seems as though the more I understand how to code and wiring functions, I become less creative in how I can apply this to real applications.
Analog output tones (with flex sensors)
I decided to re-do the tones lab this week and use flex sensors for my variable resistors, rather than photo sensors. Although I like the idea of detecting light and using that to create an output, I was feeling that my results weren’t very accurate. And finally realizing that the shop has flex sensors to rent, I went to town.
A few strange things about this lab:
The flex sensor connected to Analog Input 1 didn’t detect anything in the serial monitor. I changed the flex sensor a few times, and it didn’t seem related to the sensor itself.
Also, a question about this lab: other than declaring the global variable for speakerPin as 8, we don’t mention which analog inputs the flex sensors are connected to. How are the sensors reading the input? Why is that not important in the code?