#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int value = 4;
int pin = 24;
int LEDState=0;
const byte ValuePluss = 10; // for increment
const byte ValueMinus = 11; // for decrement
const byte buttonPin1 = 22; // the pin that the pushbutton is attached to
const byte buttonPin2 = 23;
const byte buttonPin3 = 24;
const byte buttonPin4 = 25;
const byte buttonPin5 = 26;
const byte buttonPin6 = 27;
const byte ledPinA = 4; // the pin that the LED is attached to
const byte ledPinB = 5;
const byte ledPinC = 6; // the pin that the LED is attached to
const byte ledPinD = 7;
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
pinMode(ValuePluss, INPUT_PULLUP);
pinMode(ValueMinus, INPUT_PULLUP);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(buttonPin3, INPUT_PULLUP);
pinMode(buttonPin4, INPUT_PULLUP);
pinMode(buttonPin5, INPUT_PULLUP);
pinMode(buttonPin6, INPUT_PULLUP);
pinMode(ledPinA, OUTPUT);
digitalWrite(ledPinA, LOW);
pinMode(ledPinB, OUTPUT);
digitalWrite(ledPinB, LOW);
pinMode(ledPinC, OUTPUT);
digitalWrite(ledPinC, LOW);
pinMode(ledPinD, OUTPUT);
digitalWrite(ledPinD, LOW);
lcd.setCursor(7, 0);
lcd.print("Pin-");
lcd.setCursor(11, 0);
lcd.print(pin);
lcd.setCursor(7, 1);
lcd.print("val-");
lcd.setCursor(11, 1);
lcd.print(value);
}
void loop() {
// put your main code here, to run repeatedly:
if(!digitalRead(22))
{
if(value<7)
{
value=value+1;
}
else
{
value=4;
}
delay(100);
lcd.setCursor(7, 1);
lcd.print("val-");
lcd.setCursor(11, 1);
lcd.print(" ");
lcd.setCursor(11, 1);
lcd.print(value);
}
if(!digitalRead(23))
{
if(value>4)
{
value=value-1;
}
else
{
value=7;
}
delay(100);
lcd.setCursor(7, 1);
lcd.print("val-");
lcd.setCursor(11, 1);
lcd.print(" ");
lcd.setCursor(11, 1);
lcd.print(value);
}
if(digitalRead(24)==LOW)
{
lcd.setCursor(11, 0);
lcd.print("24");
if(value==4)
{
digitalWrite(4, HIGH);
}
if(value==5)
{
digitalWrite(5, HIGH);
}
if(value==6)
{
digitalWrite(6, HIGH);
}
if(value==7)
{
digitalWrite(7, HIGH);
}
}
else
{
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if(digitalRead(25)==LOW)
{
lcd.setCursor(11, 0);
lcd.print("25");
if(value==4)
{
digitalWrite(4, HIGH);
}
if(value==5)
{
digitalWrite(5, HIGH);
}
if(value==6)
{
digitalWrite(6, HIGH);
}
if(value==7)
{
digitalWrite(7, HIGH);
}
}
else
{
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if(digitalRead(26)==LOW)
{
lcd.setCursor(11, 0);
lcd.print("26");
if(value==4)
{
digitalWrite(4, HIGH);
}
if(value==5)
{
digitalWrite(5, HIGH);
}
if(value==6)
{
digitalWrite(6, HIGH);
}
if(value==7)
{
digitalWrite(7, HIGH);
}
}
else
{
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
if(digitalRead(27)==LOW)
{
lcd.setCursor(11, 0);
lcd.print("27");
if(value==4)
{
digitalWrite(4, HIGH);
}
if(value==5)
{
digitalWrite(5, HIGH);
}
if(value==6)
{
digitalWrite(6, HIGH);
}
if(value==7)
{
digitalWrite(7, HIGH);
}
}
else
{
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
}
As per code above, I am using a MEGA board with few Push buttons and LEDs
Here I am using a counter type code to count from 4 to 7 which are also the pin number for LEDs basically
I have 4 other push buttons at pin 24 25 26 27 just to operate LEDs at 4 5 6 7
It can be done easily by giving command within the code
But now as the thread name is here
I want to make changes in the matching of Push button with LEDs randomly without use of code
Suppose our basic match from code for push button to LEDs are
24 - 4
25 - 5
26 - 6
27 - 7
Now we want to make a random match from our designed system be like
24 - 6
25 - 4
26 - 5
27 - 7
or
24 - 7
25 - 5
26 - 4
27 - 6
and so on . . .
This should not be done by using a laptop or cellphone or simply the code via IDEs
In simple sentence I want to make a system which can register a a data itself with use of some input push buttons and to operate as per data entered until the Arduino Power gets OFF
For data manipulation purpose I am using 4-7 counter here for basics
(where a 4 simple push button can also be added or a keypad can also be there in advance case)
I don't have a single idea about such type of concept
that
if it really don't exists
and I am thinking and doing silly things wrong way
or
It can be done with some advanced kind of concept or hardware add-on
and I am heading right way
Please guide me !!
May be I am not able to explain properly above so please ask but help me out !!
Just today this idea came in mind
Thanks !!!!!!!!!!!!