13. Input devices¶
This week I worked on adding a sensor to a microcontroller board that you have designed and read it. [Reference]
Group assignment¶
This week of group assignment, We try to probe an input device’s analog and digital signals.. Click HERE to see more detail of the group assignment.
Individual assignment¶
Heroshot¶
IR sensor¶
I plan to make a board that can sensor something passthrough. Because my project, the Ball-In game machine, is designed for users to get points when the props(ping-pong balls) go through the ring, and the ring is controlled by the users. And I assume that there will be a sensor or a trigger to count the ball.
So I search for what sensor I could use, and I found this, IR distance sensor.
And it’s one of the ways to detect something passthrough. So I choose this sensor for the test and my assignment this week.
PCB design¶
I’ve used my ESP32 board which is the board for final project.
Then I’ve used mods to turn it into Gcode.
And I’ve used EdytorNC to send the Gcode to the machine.
Connecting wires¶
IR sensor have three wires: GND(Ground), VCC(5V Power), SIG(Signal).
Programming¶
After making sure there are no short-circuit and wires connect mistakenly. I’ve programmed it with the code below, so the I2C LCD will display the status of the IR sensor and the Count of detections.
If the IR sensor detects nothing, reset IR_status, and shows the score and status of the sensor in the LCD.
If the IR sensor detects anything, the score increase by 1, and shows the score and status of the sensor in the LCD.
If the IR sensor keeps detecting nothing, shows the score and status of the sensor on the LCD.
Note: IR_status is a value used to prevent the score keep increasing in a detection.
Result¶
And here is the result: