ARDUINO Programming

Arduino Programming 

Heyy welcome to another blog of mine...๐Ÿ˜ญ This time round we will be doing arduino programming. Personally i hate doing programming, however i do experience some kind of excitement while doing it! Personally i feel that it is extremely hard and difficult to understand but finding out that the code works really felt like an accomplishment to me๐Ÿ‘Š


Before the start of the experiment, every group was tasked to make the pegasus's wing flap using arduino programming. That was the requirement for every group, however our group was challenged by one of the teachers where we were required to use 2 servo as well as an LED light to be put inside the pegasus. Before we were issued the challenge, what my group did for very first step was idea development. What we have decided on is that the code will function in way that it will stop after 10 times. The motor will be concealed within the body and arduino board will be hidden in the cardboard base of the pegasus, all of these is to hide all the wirings and the components for aesthetic purposes. This is how a simple programming should work.



Wing Mechanism

For the wings to move, it must be attached to the servo motor. The wings are tied together by the metal wire or a rubber band within the body. The metal wires are wrapped around the wings twice to be secure, and it has to be tight.    The other end of the metal wire is hooked onto holes on the servo blade and ensure that it is secure.

When the button is pressed, the servo will push the wire which is connected to the wing. The servo will rotate 140°, which will push the inner part of the wings forward. After 10ms, the servo will rotate back 140°, which will pull the inner part of the wings backwards. The servo will move back and forth in 140° motion, which will flap wings of the Pegasus. This motion will repeat for 10 times before coming to a stop.


Video Link: <https://youtube.com/shorts/5Ry7l2DyezU?feature=share>


Assembly



The last part is to assemble and achieve the final product. All the hardware with Arduino will be glued in the cardboard box (if cardboard box is not available, a piece of carboard will do). The servo motor will be sticked inside the Pegasus, the wires which connects to the servo motor will run down on the insides of the Pegasus leg thus wires are not shown.

Right under the Pegasus leg, there will be a small hole for the wire to run through the carboard. It is then connected to the Arduino board which is connected to a power bank and is right under the Pegasus.

Refer to the link for Winged Pegasus in Operation: <https://youtu.be/W_SbEVZZbrU>


CHALLENGEE๐Ÿ˜‰

The challenge is to use 2 servo as well as an LED light to be put inside the pegasus. There were a lot of issues doing this as initially we did not know how to connect the servo to the arduino breadboard. It was not taught to us thus we have to search online and learn how to do it ourselves. Moreover putting LED into the components is something new to us too! ๐Ÿ˜ƒ Basically almost everything we did was the same as the steps mentioned above, the hard part is incooperating the LED lights together with another set of servo motor together! The whole process of putting these things together was really messy... We spent a lot of time after school meeting up just to make this challenge work!

During the process of doing this, we have encounter some issues such as the wires are too messy and since there is many boards being used, we did not know how or where to hide it. The solution we came up with is that we made a so called platform, which is a box where we can hide all the components of the pegasus right under the pegasus. The wires of the motors will be glued onto the inner sides of the legs and the wires will run down into the box without being seen! This allows our pegasus model to be 'cleaned' of wires! As such it looks aesthetically pleasing, not some mushed up wires being clumped up together.๐Ÿ‘Œ Here is a video of how the processes went and the final video for our challenge!!! ENJOYY๐Ÿ˜Š

Individual tasks 

1.A. Potential meter

Firstly what i did here is connecting the A0, which is analog inputs which sense the gradually changing electrical signal from the turning potentiometer. The ADC will then converts the incoming analog signal between 0v-5v into a range of numbers from 0-1023 milliseconds The most essential thing is to wire the Potentiometer to the power and ground, centre pin to the A0. This is how the setup of the circuit board suppose to look like as shown below! ✊

All of these will not be able to work without a code which will run the program! 

1. At the Variable category, create a variable, in my case i create the variable as "sensorValue"
2. Drag out a set block, grab a read analog pin from the input category and place it into the set block.
3. Next grab a set built in LED to High
4. Drag out wait block, it is the delay function, drag out the "sensorValue" from the variable category and put it into the wait block.
5. Duplicate the entire section, and put it in between them around another output block and set the built-in LED low or off. It will turn the LED on, waits between 0-1023 milliseconds, and turn the LED off. The whole process will repeats ! ๐Ÿ‘Œ

This is how the board will look like when the code is run. here is another link down below incase this video do not work!


Here is how the arduino should turn out! Have fun playing with it:)

Link for simulation: 
Link for code:
Link for video:



1.B. LDR

As you can see, this is how the board is supposed to look like after connecting all the wires! 5 volts is connected to the breadboard, if the resistor is put in series, it divides the voltage based off of the resistance. ๐Ÿ˜Ž

The components we need are LDR, LED, wires, resistors, breadboard and Arduino board. In this activity, how this setup works is that, the more light the LDR receives, its resistance decreases and vise-versa. So the light will turn off once the LDR reaches its maximum light intensity.  The board is supposed to look like this as shown below! ๐Ÿ’ Left side is off and right side is on !!!

           

The code works in a way that pinmode is set to A0 as an input, as we want to read the junction of the resistor and the LDR. If we want to read, that means we want information that's the output from the sensor to be the input of an arduino. 

1. Set pinMode A0 as an input
2. At the void loop, use analogReading of the A0.
3. Type in Serial.begin(9600) so that it can measure its signal in serial monitor arduino IDE. The values will change as i move the LDR's light intensity button. It will look as shown below.
4. Type the rest of the code as shown below and press start simulation, it should work perfectly!
          

This is how the board will look like when the code is running. There is another link down below incase this video do not work!

Here is how the arduino should turn out! Have fun playing with it:)


Link for the simulation:
Link for code: 
Link for Video:



2.A. 3LEDS

The 3LEDs chosen are red, green and yellow for this activity. What i did here was i make the LED blink in specific timing, all of these 3LED lights will blink at a specific given time with a 1000ms or 1s interval!!๐Ÿ˜Œ

The pincode used for this setup is pinmode 9,10 and 12 for yellow green and red respectively. Since you are already this far into my blog, you should know where to put the power and ground wires! Refer to the picture down below if you have any issues with it๐Ÿ‘The power as well as the grounds should be connected to their respective places.

1. Type in pindMode(9,OUTPUT) since we used pin9 as an output, do this for other pin as well, which is in our case are pins 9,10 and 12 ✌
2. Last part is the basic blinking, where we put the interval between each blink as 1 second.
3. For example, once 9 is on, 10 will be closed. Once 10 is on, 12 will be closed, etc as shown down below. You can change to any pin you prefer too:) It will work just fine, but do remember to change the pin numbers.

The coding and how the board is supposed to look like is down below.

This is how the board will look like when the code is running. There is another link down incase this video do not work!

Here is how the arduino should turn out! Have fun playing with it:)

Link for the simulation:
Link for code: 
https://drive.google.com/file/d/1EnShyRuvtzMU0_SxCmJA2MK_Jde9n_-6/view?usp=sharing
Link for Video:
https://drive.google.com/file/d/1LjadoTaDHIuPt9NyrKNUpeGo9cfaJ979/view?usp=sharing

 

2.B. DC motor

Lastly, we have come to the last individual activity, we were tasked to do the DC motor which is combined together with the push button. How this is going to work is that once the button is pushed, the current will flow through the motor hence it will spin. After connecting all the wires to the buttons and the motor respectively, this is how the board supposed to look like as shown below.

 How i approach is is by watching the video on how to do the push button together with the LED lights and i tried applying the motor to the set up by replacing the LED light that was inside the setup!๐Ÿ’ค This is how to code,

1. Create a new variable called ButtonState.
2. Drag  out read digital pin from the input category and set the pin to 2 since we have chosen the pin as 2.
3. Drag out the "IF, ELSE" block, drag out math comparator block into the IF statement and drag out the buttonState and put inside that comparator block. Set to high. Thus the motor will be turned on once the button is pressed, if not it will be off.
4. Then drag out set built in to for both HIGH and LOW, thus if button state is high, motor on if its low it is offed. 
5. The codes are to be done as shown below for it to work, use it as reference:)


This is how the board will look like when the code is running. There is another link down incase this video do not work!

Here is how the arduino should turn out! Have fun playing with it:)


Reflection

In this practical, i have faced many challenges and there are ups and downs while try to attempt this coding sessions as well as practicals. First of all i am not good at coding, in fact i am horrible at it. To me, this practical took up a lot of my time, i feel that coding is like another language for me and i do not really understand it. However, as i attempt more and more of these challenges, i began to understand more on how this coding works and how to apply it for other functions as well. It was a challenge though, and it was really time consuming trying out by a 'guess and check' method as i do not know where i go wrong. It is frustrating when i do not know where i went wrong.๐Ÿ˜… Well, these are what i have felt while i was doing the individual part for relfection. It feels like a torture to me... At the end of the day, i did learn something new, so i have nothing to complain about that, the feeling of the coding actually work makes it worthwhile. 

When i was doing the challenge, my group and i was faced with numerous difficulties. Our group's was one of the hardest, at least that is what i felt as we were challenged to do 2 motos as well as combining the LED lights into the arduino board. We went out of our ways to do some extra research, we tried searching youtube on how to use the breadboard which we weren't taught. Moreover, when we were doing the challenge, we realized that the wires were everywhere and there was no place for us to hide the wires as well as the board. Additionally, we can't seem to figured out how to insert the LED lights into the pegasus eyes. 

1. How we solved the issue of the wires and the breadboard was that we thought of making a box or a.k.a a platform for the pegasus to stand on. It is basically a box which holds all the components of the pegasus model. The wires were also well hidden as it runs along the inner sides of the pegasus.

2. Second challenge was the LEDs, this one was the hardest one for us as we did not know where to start. The space inside the pegasus head was so tight that it is hard to even fit anything inside it. In the end, we came up with an idea to use a mini crocodile clips, which connects the 2 ends of the LEDs to the breadboard!!๐Ÿ‘€


References 

- Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=PC15jBx2UxI> [Accessed 24 November 2021].

- Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=iidi2wE8gok&t=124s> [Accessed 24 November 2021].

- Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=RS9zo-sxMrk> [Accessed 24 November 2021].

- Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=-EDYMQ9lczA&t=194s> [Accessed 24 November 2021].














Comments

Popular posts from this blog

HOME