Design and program a smart device that perform a certain function or solve a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code).
ماكينة كنافة نافة
Its a machine for making كنافة .
As the slide switch in on that combined with LDR sensor the machine will turn on and an LED will light up when we cover the sensor.
I was inspired by the drawing machine "Doodler," and as almost Ramadan is about to start, I decided to make "ماكينة كنافة"
Hardware components
Electronic parts
DC geared Motor
LED
9V adaptor
Jumper wires
Breadboard
Resistor
Slide switch
LDR sensor
Screw terminal block
Motor driver
Arduino UNO
Non-electronic parts
Tape
Tung depressor
Pen
Cardboard
Glue gun
BBQ sticks
Software
The action components: Motor-LED
Input : slide switch - LDR sensor
output: motor- LED
voltage source: 9V adaptor
Simulating the circuit on Tinkercad:
Wiring the electronic components:
wiring the motor driver :
two sides (blue and green wires for the motors)
the red and orange wires for the power source
(red wire--positive/ orange -- ground)
wiring the motor driver(pins) :
connecting the motor driver with the Arduino
(in1--pin8)(in2--pin7)(in3--pin5)(in4--pin4)
connecting the LED with pin9 on Arduino
(I added resistor to prevent the LED from burn)
connecting the LDR sensor with Arduino
we have 4 terminals on LDR(Analog - digital-ground-VCC)
the ground with the common ground on the breadboard- digital with pin11 on Arduino-VCC with the common positive on breadboard
connecting the Arduino with breadboard
(red wire connecting between pin (5V) and common positive on breadboard)
(purple wire connecting between ground on Arduino and common ground on bread board )
connecting slide switch to the breadboard and Arduino
(the grey wire to common ground on breadboard-orange wire to pin 6 on Arduino-brown wire to common positive)
connecting Screw terminal block to the breadboard to power the circuit
(red wire common positive-black wire common negative)
by plug in the 9V adaptor the circuit will get the needed power
the whole electric circuit
the circuit while working
started to simulate the circuit using tinkercad.
building the electronic components together.
coding the circuit using "Arduino software C"
define the pins first which one is input and which is output.
adding the condition "if-else" to control the LRD sensor :
If
else--if the slide switch is high then pin in1-in2 and pin for LED all are going to e high
else all pins are going to e low
testing the circuit first before being added the cardboard.
adding the circuit to the cardboard enclosure.
connecting the machine with the power source.
after connecting and coding the circuit the circuit didn’t work.
solution:
by the help of one of my colleagues we reconnect the circuit -as explained at design part-, then :
debugging the code it was correct.
troubleshooting the circuit by checking the connection of each component, and there was a short circuit in one of them by rewiring it, it worked.
I wasn’t connecting the sensor correctly so we reconnecting the LDR sensor with Arduino as the following:
we have 4 terminals on LDR(Analog - digital-ground-VCC).
the ground with the common ground on the breadboard- digital with pin11 on Arduino-VCC with the common positive on breadboard.
It will help to build the electric circuit of the final project understand the integration between all the components.
Being able to build this machine😁