Arduino Programming Entry

 In the Arduino Programming Entry I got to do an individual task, that required me to use Tinkercad to make 4 different codes, for 4 different problems. Tinkercad is a tool that allows us to simulate Arduino programming and make our own circuits.

 I learnt that there is a difference between input and output devices. Input devices are devices that are used to send data and information. In our context, an input device sends data and information to the arduino board such as  photoresistor. On the other hand, output devices are devices that receives the data to do or control something such as a servo motor and DC motor.

INPUT DEVICES

a. Interface a Potentiometer Analog Input to maker UNO board and measure its signal in serial monitor Arduino IDE

In the first input device problem, I had to make a potentiometer analog input to maker UNO board. It is an input device as it controls the voltage to the arduino board to light up the LED. By following one of the tutorial videos on youtube in Figure 1, I managed to make the set-up as shown in Figure 2 and 4.


Figure 1: YouTube video tutorial

Figure 2: Potentiometer setup

The YouTube tutorial also showed how to configure the Arduino code. Figure 2 shows how the coding look like (Click on the image to enlarge it!). From the code, it can be intepreted that the sensor value is taken from pin A0. As the knob of the potentiometer is turned to change the voltage, the LED light will be either lighted up or off. As there is a void loop in the code, the LED light will keep lighting up and off.


Figure 3: Potentiometer codes


Figure 4: Potentiometer setup with the measurement device


Figure 5: Video of Potentiometer setup with the measurement device in action

You may interact and tinker with the circuit board below. Click on the "Code" tab or click here to view and download the potentiometer code!


b. Interface a LDR to maker UNO board and measure its signal in serial monitor Arduino IDE

The second task that I had to do was to set up a LDR also known as a photoresistor into maker UNO board. It is an input device as it controls the amount of resistance in the maker UNO when there is a change in luminosity on the photoresistor. Following a YouTube tutorial, I managed to do the same setup as shown in Figure 7. 


Figure 6: YouTube video tutorial of LDR problem


Figure 7: Photoresistor setup with measurement device

In Figure 8, the code can be intepreted that the sensor value will be taken from pin A0 which is the input of the photoresistor setup. The LDR controls the resistance of the setup where the higher the intensity of light on the LDR, the less resistance to current there will be in the circuit which causes light in LED to be brighter. This setup is very similar to the Potentiometer setup except that now there is a delay of 100 miliseconds of how fast the LED light changes to the change of light intensity on the LDR or photoresistor.


Figure 8: Photoresistor arduino code


Figure 9: Video of Photoresistor Tinkercad in action

You may interact and tinker with the circuit board below. Click on the "Code" tab or click here to view and download the potentiometer code!
     
OUTPUT DEVICES

a. Interface 3 LEDs (Red, Yellow, Green) to maker UNO board and program it to perform something(fade or flash etc.)

For the first output device problem, I had to make a setup where 3 LEDs of colours Red, Yellow and Green would fade. I followed the YouTube tutorial as shown in Figure 10. Figure 11 shows how the setup will look like.


Figure 10: YouTube video tutorial on LEDs


Figure 11: 3 LEDs setup

Figure 12 shows the programming code of the LED setup. It can be intepreted that when there is an input, there is an output at pin 3, 6 and 9. When there is an input, Red LED that is connected to pin 9, will light up for 20ms and will immediately light off at 0ms. Afterwards, pin 6 will light up of 20ms and will immediately light off at 0ms. The same thing will happen to pin 3. This will form a continous loop which looks like a traffic light.


Figure 12: LED arduino code


Figure 13: Video of 3 LEDs in Tinkercad fading in action

You may interact and tinker with the circuit board below. Click on the "Code" tab or click here to view and download the potentiometer code!

b. Interface the DC motor to maker UNO board and program it to on and off using push button on the board

Lastly, I had to make a DC motor setup. Figure 14 shows how I set it up.


Figure 14: DC motor setup

Figure 15 shows the code where it can be intepreted that when there is an input at pin 7,there will be an output at pin 13. The pushbutton will be the input device whereas the DC motor will be the output device where when pushed, it will cause the DC motor to rotate. When the pushbutton is not pushed, the DC motor will not rotate. There is also a 200ms delay where it will take 200ms for DC motor to react to the button being pushed.


Figure 15: DC motor arduino code


Figure 16: Video of DC motor in Tinkercad in action

You may interact and tinker with the circuit board below. Click on the "Code" tab or click here to view and download the potentiometer code!


PROBLEMS FACED: 
 The problems that I faced while doing the Arduino programming on Tinkercad were that the challenges were different from what I am used to and that the way of coding on Tinkercad was different. I am used to only having the push button as an input device but the tasks that I had to do used Photoresistor and Potentiometer. Because of that, I thought that the coding would be very different and changed the codes many times to make them different but they are not at all. After knowing that they are actually not different, it made the coding easier. Tinkercad introduced another way of coding which was to use "blocks" of codes. At first, I did not know how to use it but after watching the YouTube video about how to use the "blocks", I only managed to gain a slight understanding of it. I still prefer typing down codes as I am used to it and that makes it easier for me.

LEARNING REFLECTION:
Through these individual assignment, I got to learn more about Arduino Programming. It had been a very fun but frustrating experience while learning to code using Arduino. This is due to the fact that I am very new to coding which can be challenging for me when I face problems. Troubleshooting codes takes a long time for me as sometimes I may have mistyped or maybe forgotten a bracket in the code which makes me feel frustrated. However when I managed to troubleshoot the problematic code, it makes me feel accomplished with what I have done to the code. When I started learning about Arduino I was quite bad at it as I did not know what some of the functions and code means. Now, I understand what they mean and am able to use them properly when forming the code in the individual assignment. I got to be creative with the coding where I was able to make custom changes here and there without any hesitations. Although the challenges in the individual assignment were different from what I was used to, the functions and logic remains the same. This makes it fun for me as I can tinker around with the code freely. Overall, Arduino Programming has been a very useful and fun experience which will really help me in my upcoming Final Year Project!

No comments:

Post a Comment

HOME

  Hello! I am Firmanshah Bin Bakhtiar, a student taking Diploma in Chemical Engineering at Singapore Polytechnic. I will be sharing more abo...