Farmer is a game that has features like the final project ideas feature, so I want to test one of these features in this game.
to build and simulate my circuit before making it IRL
Arduino IDE
upload my code to my Arduino
To glue cardboard
To prototype the carousel
is a radiation-sensitive optoelectronic component with a spectral sensitivity in the infrared wavelength range 780 nm
Servo Motor
rotate an object with great precision
visual or textual display
to control an electrical circuit in which the operator manually presses a button to actuate an internal switching mechanism
used to produce a tone, alarm or sound
integrated into a variety of electronic projects
emits light when an electric current flows through it
crocodile wires
used for making electrical connections
for building temporary circuits
330-ohm resistors
limit current
to wire it all up
Open Tinkercad and click on create tab and select circuit
Use the bar on the right to search for the components Search for the first component "breadboard" then drag it
Then drag the rest of the components of the circuit
LCD I2C
Arduino uno
LED & Resistor
IR sensor
Servo
push button
Buzzer (piezo)
Connect the servo with power and ground and pin 3
Connect push button with the resistor and pin 2
connect the LED to pin 4
start to organize what we want to do for coding
i used if else condition
Wire.h: This library is used for I2C communication, which is necessary for the LCD display.
LiquidCrystal_I2C.h: This library is used to control the I2C LCD display.
Servo.h: This library is used to control the servo motor.
Servo Myservo: Creates a servo object to control the servo motor.
int pos = 0: Variable to store the servo position.
int pinbut = 2: Pin connected to the pushbutton.
int pinLED = 4: Pin connected to the LED.
LiquidCrystal_I2C lcd(0x27, 16, 2): Initializes the LCD display with the I2C address 0x27, 16 columns, and 2 rows.
int IR = 11: Pin connected to the IR sensor.
int buzzerPin = 7: Pin connected to the buzzer.
int count_value = 0: Variable to store the count of detected objects.
pinMode(pinbut, INPUT): Sets the pushbutton pin as an input.
Myservo.attach(3): Attaches the servo to pin 3.
lcd.init(): Initializes the LCD display.
lcd.backlight(): Turns on the LCD backlight.
pinMode(IR, INPUT): Sets the IR sensor pin as an input.
pinMode(buzzerPin, OUTPUT): Sets the buzzer pin as an output.
lcd.begin(16, 2): Sets up the LCD with 16 columns and 2 rows.
lcd.print("HELLO FARMER"): Displays "HELLO FARMER" on the LCD.
delay(2000): Waits for 2 seconds.
Servo and LED Control:
If the pushbutton is pressed (LOW), the servo moves to 175 degrees.
If the pushbutton is not pressed (HIGH), the servo moves to 90 degrees.
If the pushbutton is pressed, the LED is turned off; otherwise, it is turned on.
IR Sensor and Buzzer Control:
Reads the value from the IR sensor.
If an object is detected (val == 0), the count is incremented, and the count is displayed on the LCD.
The buzzer sounds for 1 second when an object is detected.
If no object is detected, the buzzer is turned off.
This code sets up a system where:
A servo motor and LED are controlled by a pushbutton.
An IR sensor detects objects, increments a counter, and displays the count on an LCD.
A buzzer sounds when an object is detected.
Prepare all the electric circuit components to build the circuit.
Build the circuit as designed on Tinkercad. After powering the circuit, the light are connected in arduino.
Press the push button, the circuit is working perfectly.
figure out if the distance of IR sensor is fit
Start making the cardboard enclosure with the right dimensions to count points
i faced a problem when i connect the piezo to the LCD the sound isnt match with counting point so i had to change the code to delay it with if condition
faced problem hot put the sensor in the right position
In the final project, I need to make sure that the sensor is in the right place with right numbers
Break your goals into small steps (THINK BIG but start small)