Input Device | Week 12
Here int his week I have made a Counter which will glow LEDs when Button 1 is pressed and When Button 2 is pressed it will decrese LED.
Input Device Circuit Layouts
LED is kept on Pin no 0,1,2,3,7,10
Logic is added as counter.
I have given Bluetooth RX TX in the circuit so I can use this for Interface week also.
const int buttonPin = 9;
const int buttonPin1 = 8;// the pin number of the pushbutton input pin
int ledPins[] = {0, 1, 2, 3, 7, 10};
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
int buttonPressCount = 0;
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonPressCount1 = 0;
int numberOfLED = 6;
void setup() {
// initialize the LED pin as an output:
for (int i = 0; i < numberOfLED; i++) {
pinMode(ledPins[i], OUTPUT);
}
pinMode(buttonPin, INPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
buttonState1 = digitalRead(buttonPin1);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == LOW) {
for (int i = 0; i < numberOfLED; i++) {
if (buttonPressCount % numberOfLED == i) {
// turn LED on:
digitalWrite(ledPins[i], HIGH);
} /*else {
// turn LED off:
digitalWrite(ledPins[i], LOW);
} */
}
buttonPressCount++;
delay(400);
}
if (buttonState1 == LOW) {
for (int i = 0; i < numberOfLED; i++) {
if (buttonPressCount1 % numberOfLED == i) {
// turn LED on:
digitalWrite(ledPins[i], LOW);
} /*else {
// turn LED off:
digitalWrite(ledPins[i], LOW);
} */
}
buttonPressCount1++;
delay(400);
}
}
In input week task was to read.
I was trying to make as simple for kids to understand. I found Sensors need a specific environment to test. My students use to press net in ultrasonic.
So this time I designed a circuit with 6 on board LEDs.
with 2 Switch as Input, this will be tactile based and durable.
So my code will read input from Switch and send to Controller Atty Tiny 44.
Ultrasonic as Input Device in Final Project
I made a board with 328p-au micro. I modified the Satsha KitComponents I added
- 1 - 6 pin header for two servos
- 1 - 4 pin header for LED's I2C
- 1 - 4 pin header for Ultrasonic
- 1 - 4 pin header for Bluetooth