Assignment Objective:
This week's assignment was about getting more familiar with Arduino, so we was asked to design a smart circuit using Arduino UNO, which has an input component that communicate with an output component.
Idea:
I have browsed many projects ideas on Arduino Hub and YouTube for inspiration, and while skimming through different projects, I thought about making an electronic dice that work just by punting your finger above it! it's cool, suitable for lazy player, will not get lost, and is of a big handy if the word turned to "A quit place" movie and you want to play a dice based game :D
Electronics:
1- Arduino UNO
2- Breadboard
3- Ultrasonic sensor (HC - SR04)
4- Jumper wires
5- 7-Segments display (cathode type)
6- Resistors
7- Red LED lamp
Software:
1- TinkerCad (for simulating the circuit and coding the Arduino board using codeblock)
2- Aruino IDE (for uploading the C++ code to the arduino board)
Circuit connection
How the Circuit work:
The dice consists of one input component (the ultrasonic sensor) and two output components (the LED and the 7segment display). It works as follow: when your finger/hand come close to the ultrasonic sensor (distance < 20 cm) the Arduino board generate a random number between 1 and 6, then display it on the 7 segments display and the LED turns on.
Design on Tinkercad:
Firstly, I connected all the components on the breadboard and to the Arduino as shown, then I wrote the code for the Arduino by using the code blocks. Finally, I translated the corresponding C++ code to Arduino IDE to upload it for the real UUNO board.
Coding steps:
1- I made an if-else statement to monitor the readings of the ultrasonic sensor, so that if there is an object on a distance less that 20 cm the dice will work, and else everything turn off
2- In the working statement, I used random function to generate a random value between 1 and 6 and saved this value in a variable called "n"
3- then by using nested if, I began to inspect the value stored in the variable "n", and accordingly this value will be displayed on the 7 Segment display for 1 second
I connected all the component on a big breadboard using jumper wires, I used resistors with the 7 segment and the LED for protecting them from extra voltage, as each bulb need on average 2 volts while the Arduino work with 5 volts
Circuit wiring
In the end of week session while working on the group projects, we all brain stormed the way the code should be implemented, which helped in connecting good points of view from all of us that contributed in conducting the right code
I got stuck at the assignment, as I was thinking of implementing it by using an LCD display, but the LCD that I have in my kit is connected to an I2C module, which is not supported on tinkecad, so I decided to implement the project using the 7 - segment display
Arduino is for sure the brain of my final project, that will control all the sensors and motors that I will use in the project, so this week very helpful in making e more familiar with Arduino and how to connect and control different components with it.
Title of Media