sensory awareness for children device

Not sure if this should be in programming or if here is better, also if anyone would be interested in helping with the coding part of this then please post here or pm me.

Ive been asked by a friend who works with children if i could help with an idea they had.
I dont understand all of it (lots of things to do with kids growing up and learning) the basics are she would like what is basically a light (or any other physical display) board that changes in different ways when the inputs are pressed.

Ive done a stupidly simple design on fritzing and explained it to her and she thinks it will work. Basically when the input switches are pressed it changes which LED is lit up, turning all the others off.
Input 1 is up in number.
Input 2 is down in number.

For each time input 1 is pushed it effectively adds one to the count of LED, so press it 3 times and in sequence the LEDss will light up until number 3 is on.
use input 2 and it will subtract 1 from the count. So if were at input 3 and press it twice the input 1 will light up.

The idea is to have different color lights, ie a red, green, yellow, blue or in the future have things other than just LEDs. such as a spinning wheel a led chaser and things like that.

Now comes the problem, i have absolutely no idea where to start with the programming of this. I’ve used other peoples code before and tweaked it for my own purposes but i cant do this from scratch.
Is anyone willing to help who knows about this.

I should also mention that this is not commercial thing, and will be open sourced if it turns out to be effective.

Don't use pin 1 as an output pin for a LED - it is also the TX pin, and either function could interfere with the other. Your push buttons are not operational. They have only a pin connection, but nothing on the other side of the switch. I would suggest grounding the other contact.

Then take a look at the Examples menu, particularly Button and DigitalInputPullup. Work with the code in those examples to build your program. Come back when you hit a wall, and folks here will help you over it.

ok ive changed a few things. and have a code that might work, can someone read over it? Im waiting for another UNO to arrive to test it.


// this constant won't change: const int buttonPin1 = 6; // the pin that pushbutton 1 is attached to const int buttonPin2 = 7; // the pin that pushbutton 2 is attached to const int ledPin1 = 2; // the pin that the LED 1 is attached to const int ledPin2 = 3; // the pin that the LED 2 is attached to const int ledPin3 = 4; // the pin that the LED 3 is attached to const int ledPin4 = 5; // the pin that the LED 4 is attached to

// Variables will change: int buttonPushCounter = 0; // counter for the number of button presses int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button

void setup() { // initialize the button pin as a input: pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); // initialize the LED as an output: pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); pinMode(ledPin3, OUTPUT); pinMode(ledPin4, OUTPUT); // initialize serial communication: Serial.begin(9600); }

void loop() { // read the pushbutton input pin: buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state if (buttonState != lastButtonState) { // if the state has changed, increment the counter if (buttonState == HIGH) { // if the current state is HIGH then the button // wend from off to on: buttonPushCounter++; Serial.println("on"); Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); } else { // if the current state is LOW then the button // wend from on to off: Serial.println("off"); } // Delay a little bit to avoid bouncing delay(50); } // save the current state as the last state, //for next time through the loop lastButtonState = buttonState;

// turns on the LED every four button pushes by // checking the modulo of the button push counter. // the modulo function gives you the remainder of // the division of two numbers: if (buttonPushCounter % 1 == 0) { digitalWrite(ledPin1, HIGH); } else { digitalWrite(ledPin1, LOW); }

if (buttonPushCounter % 2 == 0) { digitalWrite(ledPin2, HIGH); } else { digitalWrite(ledPin2, LOW); }

if (buttonPushCounter % 3 == 0) { digitalWrite(ledPin3, HIGH); } else { digitalWrite(ledPin3, LOW); } if (buttonPushCounter % 3 == 0) { digitalWrite(ledPin4, HIGH); } else { digitalWrite(ledPin4, LOW); }


Please read this:- How to use this forum Because your post is breaking the rules about posting code.