Never Have I Ever Arduino Project - Dhruviben Bhagat 846946

by 846946 in Circuits > Arduino

151 Views, 0 Favorites, 0 Comments

Never Have I Ever Arduino Project - Dhruviben Bhagat 846946

spine the wheel 33.jpg

Hello there, my name is Dhruvi and today I will be showing you my FE. As for this project, I have created a Never have I ever game. The project uses Arduino to create a fun and interactive system. It combines different components like buttons, lights, a motor, and a sensor to control things. With the provided code and connections, you can press buttons or use a remote control to make the motor move and turn on/off the lights. It's a hands-on way to learn about Arduino, electronics, and coding. You can explore and play with the system to see how different inputs affect the motor and lights. It's a great project to get started with Arduino and learn by doing!

Downloads

Supplies

ardunoooo.jpg
led1.jpg
pushbuttonperiod.jpg
servomotor 1.jpg
10k ohms.jpg
330omhs.jpg
irrmote.jpg
ir 1.jpg
wiresss.jpg
breadboradslay.jpg

- x1 Arduino Uno

- x2 LED-> prefer red and green

- x2 Push button-> one for each LED

- x1 Servo motor

- x4 Resistor-> (2) 330 Ohms & (2) 10k Ohms

- x1 IR receiver

- x1 IR receiver remote -> make sure the remote has a strong connection/ any remote will work

- Wires 

- x1 Breadboard

Research

spine the wheel 2.jpg

When thinking of what I should build for my FE, I deiced to do some research, look into other project and try to find some inspirations or some idea. Looking through a lot of project, and found that I would like to input a servo motor into my project, but how I should make it into a project. Then I came across this website called Spin the Wheel , that inspired me do to a spin a wheel type of project.


When going through the website, I learned that the creator wanted to create a similar game to spin the wheel. Then it got me thinking, how about making it into a fun party game of never have I ever. Later, I thought of why not adding a yes/no situations with a remote actions too. So an idea clicked into my head on how I should make my FE project.

How Each Component Will Work

led1.jpg
servomotor 1.jpg
ir 1.jpg

2 LED - red and green  

When one of the buttons is pressed, the servo will either turn counterclockwise or clockwise. If the button for the red led is pressed, then the servo will turn clockwise, and if the button or the green led is pressed then the servo will turn counterclockwise. This will make the game more interesting since the servo isn’t turning in one direction.  So the red led button will make the servo motor turn counterclockwise, where the green led button will make the servo motor turn clockwise. 

Servo motor 

The servo motor will represent the hand in the spin the wheel, the handle will turn only when the button are pressed and they will spin in the opposite direction * as the code was made*. The servo motor will do a quick spin when the IR remote “turns it on”, otherwise it will spin 

IR receiver 

The IR receiver will either turn on or off the servo. So when the power button is pressed on the remote, the servo will do a quick spin to indicate that it is on now..  


Wiring

TinkerCAD!.JPG

As for the wiring part I have given you a TinkerCAD and real-version for help/guide.


1. Connecting the Base - Power and Ground

We have to make sure that the ground and power are connected to the breadboard or else, nothing will work. It is better to use the 5V then the 3.3V.

2. Push Button

Connect one leg of the push button to a digital pin on the Arduino board, such as pin 11. Connect the other leg of the push button to the ground (GND) pin on the breadboard. Optionally, add a pull-up or pull-down resistor to ensure stable button readings by connecting a resistor between the digital pin and either VCC or GND.

3. Servo Motor

Connect the power wire (red) of the servo motor to the breadboard. Connect the ground wire (brown) of the servo motor to the GND pin on the breadboard. Connect the signal wire (orange) of the servo motor to a digital pin on the Arduino board, such as pin 5.

4. LED

Connect the cathode (shorter leg) of the LED to a current-limiting resistor, such as a 220-470 ohm resistor. Connect the other end of the resistor to a digital pin on the Arduino board, for example, pin 12 for the red LED or pin 10 for the green LED.

5. IR receiver

Connect the VCC pin of the IR receiver module to the breadboard. Connect the GND pin of the IR receiver module to the GND pin on the breadboard. Connect the signal pin of the IR receiver module to a digital pin on the Arduino board, such as pin 4.


Code - Part A

part1 of code.JPG

Now for the coding, to begin the code, you will need to start with the variables. This is going to set everything and makes sure that the code will run nicely. Make sure to remember which part is named what, and not to mix up anything.

The int keyword is used to declare and define integer variables. These variables are used to store specific values related to the program's functionality. For example, int servoPin = 5; declares an integer variable named servoPin and assigns it the value 5, representing the pin number for the servo motor. Similarly, other int variables like RedLed, GreenLed, RedButton, GreenButton, irPin, and code1 are declared and assigned values that correspond to pin numbers, specific codes, or other relevant information. These variables are then utilized throughout the code to control various components, perform conditional checks, or handle specific scenarios. The int data type ensures that these variables can store integer values within the specified range, allowing for accurate and efficient manipulation of numerical data in the program.






Code - Setup

part2 of code.JPG

The void setup() function in Arduino is where you set things up before your program starts running. It runs once at the beginning and prepares everything for the main part of your code.

Servo Initialization:

It sets up the servo motor by attaching it to pin 5 using servo.attach(5).

It positions the servo at 90 degrees using servo.write(90). This is the initial position.


LED Initialization:

It prepares the LED pins (RedLed and GreenLed) to work as outputs, which means they can turn on and off.


Button Initialization:

It configures the button pins (RedButton and GreenButton) to work as inputs, so you can read their state (pressed or not pressed).


IR Receiver Initialization:

It sets up the IR receiver pin (irPin) as an input, allowing it to receive infrared signals.


By performing these setup tasks in void setup(), you ensure that the servo, LEDs, buttons, and IR receiver are ready to be used in the main part of your code.

Code - Loop

PARt3A of code.JPG
PART3B of code.JPG

The void loop() function in Arduino is like the brain of your program. It runs continuously, repeating the same set of instructions over and over again. It's where you write the code that controls what your Arduino board does.

Inside the void loop(), you can check for certain conditions or events, like button presses or sensor readings. Based on those conditions, you can make the Arduino do different things, like turning on LEDs, moving a servo motor, or sending signals to other devices.

So as you can see...

The first two if statements check the state of the RedButton and GreenButton. If the RedButton is pressed (its digitalRead is HIGH), it turns on the RedLed and moves the servo to position 180. If the GreenButton is pressed, it turns on the GreenLed and moves the servo to position 180. If neither button is pressed, the corresponding LED is turned off.

IR Receiver:

The code checks if there is an incoming IR signal by calling irrecv.decode(&results). If a signal is received, it further checks if the value matches code1 (in this case, 857). If the received signal matches, it moves the servo to position 90. After processing the IR signal, the irrecv.resume() function is called to enable the receiver for the next signal.

Continuous Execution:

The void loop() function runs continuously in an infinite loop. It keeps checking the button states, IR signals, and performs the corresponding actions based on the conditions. It does this repeatedly, allowing for real-time responsiveness to user inputs or external events.


Demo Video

Here is the final video and code!