Week 6

barrier gate

Ideation

Tell us about your assignment's idea for this week. Why do you care about this idea? What inspired you? (Please include images or links to sources of inspiration)

the assignment this week is to Build and Program a smart circuit using an Arduino UNO which reads a signal from an input component (Sensor, Switch, or variable resistor) to control an action component (Motor, Buzzer, LED...etc) using Code Blocks.

My idea this week was a barrier gate i searched online and choose these tutorial but changed the components a little bit, it have 2 led lights a red and a green one and a push buttons so when the button is pushed the motor rotates ,the green led is on and the gate opens and then it waits for 2 second as the car cross the gate then the motor rotate in the opposite direction and the red light is on till the gate is closed.

Tool Chain

Which software/machines/materials did you use in the assignment? Why?

Make sure to search for the datasheet of the components before connecting it to know its specifications( safe range of voltage and current intensity and connections)

Circuit Components:

dc geared motor (action)

push button (input)

led light (action)

breadboard and jumper wires

Arduino Uno (brain)

220 ohm resistor

H-bridge motor driver L298

to build, code and simulate the Circuit 




Arduino IDE

Design/Preparation Process

Explain the design and/or preparation process of your assignment. How did you use the tool or software to design and/or prepare your assignment before fabrication/implementation?

1st. we designed the circuit on tinker cad using:

so we have 2 led light, each is connected in series to a 220ohm resistor (because it will be powered from Arduino 5v pin) then the two terminal of this circuit and the terminal of the motor will be connected it parallel all on the same ground but on different pins (keep in mind to check the polarity of the led) then the switch connected to the ground and to a pin to take the input signal from the switch and depending on that reading it control the motor and the leds

note: if you want to make the same project i recommend to use a servo motor instead of the dc motor so you could open and close the gate (but mine didn't work in time so i changed it to keep moving forward)

then its code time

so if the push button is pushed then the green light(pin10) and the motor(pin 7) are high for 2 seconds and then everything is low for 2 seconds then the motor rotates in the opposite direction and the red light is on for 2 seconds and that's it.

then i copied the text and pasted it in Arduino ide and changed the "INPUT" of pin 7 to "INPUT_PULLUP" and uploaded the code.

TINKERCAD.mp4

Development/Implementation Process

Explain the development/implementation process of your assignment. How did you use the machine/tool to manufacture or implement the design of your assignment?

then we build the actual circuit so each led is connected to a resistor 220ohm and then to the ground and the other terminal to a pin( green ,10) ,(red,11) and the switch is connected to the ground and to pin 5 then the H- bridge there are two pins for powering it so ground and 12v i connected it to a 9 v adapter and it take 2 pins from the Arduino (pin 3 and 4) beside the speed controlling pin 9 and then the motor is connected to it (make sure the input and the output pins are for the same motor as it can control two motors together) last we had to make common ground and thats it. 

circuit.mp4

Overcoming Challenges

What kinds of challenges or problems did you face while doing the assignment, tutorials, or exercises?  How did you solve them? Did you ask for help from an instructor or peer? Please provide a link to the tutorial or article that you used to solve your problem (if any)

my first idea this week was to make automatic fan whose speed would change depending on the temperature so i used LM35 and a dc 5v fan but making the fan work was a challenge actually (i mentioned how we made that in week 7), then the temperature sensor LM35 is not included in tinker cad library so we use TM36 instead in simulation, i used the temperature reading and mapped it to 255 as it is the max output signal but that made the fan speed very low (600 RPM when the temp is 125 degree :D ) and that wasn't logically right even the led light was faded so "Mohamed Adel" recommended to read the sensor as an analogue read not a temperature read but that didn't work very well too so lastly he found the way by taking the range of the analog read of the sensor and doing the math to convert this reading to the normal range of signal (0-255) we tried the equation and it finally worked in simulation.

at this point all was good but as expected that didn't last long, after making the circuit i copied the code and tried to make that work but it didn't the temperature reading was wrong i tried using dht11 to check that i checked with " Mohamed Abd El-Moaty" as we used the same components this week and he made me notice that i didn't change the code as i changed the sensor to LM35, so i changed it but the reading become zero i serial printed the reading step by step and found where the problem happens, changed the equation and finally the reading is right.

then there is a another problem how would we control the fan speed as we used a relay to control it and we can't give it an analoge read it is ether opened or closed and that's it so we had to use motor driver to control the speed which we tried to use with the fan and couldn't make it work so at this point i gave up the idea maybe i will try that but not now so i changed the idea and that's it all is good i think.

Assignment Design Files