Hi guys, new to all this and have been playing with code to try and get my project running but struggling somewhat! Here is what I need if anyone can help.
Hardware: arduino uno. 16x2 lcd. I have from the truth table 9 possible inputs.
What I want to happen is for binary:
0000 to display "No radio input"
1000 to display "160m"
0100 to display "80m"....etc
So far I have figured how to upload some code I got from the net and kinda dissected it a little. Basic stuff to you guys. Sorta figured how to assign pins to the LCD and put my name on it.
I found some code that almost does what I want but cant figure it out.
Some help tuning it would be great. If I see in any code you can provide withjust one combination of input say 0001 and it displays "160M" then I think I can copy co creat all 9
This is the code I have been playing with...
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte bcdInputA0 = 7; // 10k pull down resistor
const byte bcdInputA1 = 8; // 10k pull down resistor
const byte bcdInputA2 = 9; // 10k pull down resistor
const byte bcdInputA3 = 10; // 10k pull down resistor
int solenoid = 6; // output to mosfet
static int Sequence = 0;
int A0state = 0;
int A1state = 0;
int A2state = 0;
int A3state = 0;
void setup()
{
// put your setup code here, to run once:
pinMode(bcdInputA0, INPUT);
pinMode(bcdInputA1, INPUT);
pinMode(bcdInputA2, INPUT);
pinMode(bcdInputA3, INPUT);
pinMode(solenoid, OUTPUT);
lcd.begin(16, 2);
lcd.print("Hello");
lcd.setCursor(0, 1);
lcd.print("select sequence");
} // end of void setup
void loop()
{
// put your main code here, to run repeatedly:
A0state = digitalRead(bcdInputA0); // LSB
A1state = digitalRead(bcdInputA1);
A2state = digitalRead(bcdInputA2);
A3state = digitalRead(bcdInputA3); // MSB
// lots more code here!!!
// e.g. if A0 =1, A1=0, A2=1, A3=0, that is 0101 (5) in binary
// that will select switch case 5 and so on...
// only codes available from external circuit are
// 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001
switch (Sequence)
{
case 0:
// code to display sequence 1 on lcd
lcd.print("sequence 1");
digitalWrite(solenoid, LOW);
break;
case 1:
// code to display sequence 2 on lcd
lcd.print("sequence 2");
digitalWrite(solenoid, LOW);
break;
case 2:
// code to display sequence 3 on lcd
lcd.print("sequence 3");
digitalWrite(solenoid, HIGH);
break;
case 3:
// code to display sequence 4 on lcd
lcd.print("sequence 4");
digitalWrite(solenoid, LOW);
break;
case 4:
// code to display sequence 5 on lcd
lcd.print("sequence 5");
digitalWrite(solenoid, HIGH);
break;
// etc etc
} // end of case
} // end of void loop
Also where does the ground from my input device connect? Next to i/o13 maybe?
Many thanks in advance