Saturday, November 27, 2021

Arduino programming

For this week, after learning about the Arduino board and some components that can be used with Arduino board, we were tasked with 4 tasks.
  • Interface a Potentiometer Analog Input to maker UNO board and measure its signal in serial monitor Arduino IDE.
  • Interface an LDR to maker UNO board and measure its signal in serial monitor Arduino IDE.
  • Interface 3 LEDs (Red, Yellow, Green) to maker UNO board and program it to perform something (fade or flash etc)
  • Interface the DC motor to maker UNO board and program it to on and off using a push button on the board
I was not able to participate in the on-campus practical as I was having a fever, I would be using photos of the aurdino board from my teammates. 

Firstly. I used thinkercad to trial the codes. I also have embed my finished work on thinkercad. 

With the help of my teammate, i was able to design the board and the code needed to measure its signal.

potentiometer
 


The LED began flashing when the board was physically replicated. The frequency of the LED may be changed by rotating the potentiometer. The frequency of blinks drops as I crank the potentiometer clockwise, but it increases as I turn it anti-clockwise. This is due to the fact that turning the potentiometer clockwise increases the resistance. The sensorValue will increase when the resistance rises, causing the LED to blink less frequently, and vice versa.
In order to measure its signal in the serial monitor, I added Serial.begin(9600); under voidsetup and Serial.println(sensorValue); under voidloop so that the serial monitor will monitor the sensor value which is the potentiometer. Whenever I turn the potentiometer, the serial number will change.


A: At lowest point (Left side of the meter)
B: Turning to the middle point 
C: Turing to the end point (Right side of the meter)


LDR

For the LDR, I know that the LDR has to be in series with the LED so that the LED will be affected by the LDR. So this is how it looks like in tinkercad.




 

I also wanted the LED to blink continuously and for the LDR to modify the brightness of the LED as the light intensity changes. I understood that as the light intensity increased, the resistance of the LDR decreased, and vice versa, thus the LED would glow brightest in a bright room and dimmest in a dark room, based on my previous experience. The blink LED will have the same code as activity 1. My theory is correct after testing it with a real board. Here's a shot of the LED.



3 LEDs

I was able to connect the three LEDs (Red, Green, and Yellow) to L13, L11, and L9 on the board in Tinkercad using what I learned in the first assignment. I also need to program it such that all three LEDs blink in unison in a loop. This may be accomplished by three times replicating a single LED flashing code and changing the L. (value). Here's a screenshot of my Tinkercad. The delay is 1 second and may be adjusted by adjusting the delay value ().





DC motor



No comments:

Post a Comment