i have created a little program where if a button is pressed a lcd will display text. it will then display different text when it is released. i used a simple if statement which works fine
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int analogInPin = A0; // Analog input pin that the Button is attached to
const int analogOutPin = 9; // Analog output pin that the Servo is attached to
// read the value of the button to see if it is high or low
int sensorValue = 0; // value read from the pot
int outputValue = 0; // output value to the LCD and Servo
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// tell arduino how many rows and collums lcd has
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Press The Button!");
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
if (outputValue == 0)
// if statement saying if the button is not pressed (0) then print one value
{ lcd.print ("Thankyou") ;
}else
// when button is pressed say this value
{lcd.print ("HELP ME PLEASE!");
}
//set the cursor to the first point on the lcd to display values
lcd.setCursor(0, 1);
}
i wish to expand it now to include multiple variations. i have set up an array of strings and a random loop but it doesnt like it. can someone help me
long randNumber;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//string array for when button is not pressed (Low)
char* stringLow[]={"Thankyou", "Thanks very much", "YEAH BABAY"
"About Time!" "Get In There"};
//string array for when button is not pressed (High)
char* stringHigh[]={"HELP ME!", "Cmon Please", "Its cold Help!",
"Cmon do something", "just push the button"};
const int analogInPin = A0; // Analog input pin that the Button is attached to
const int analogOutPin = 9; // Analog output pin that the Servo is attached to
// read the value of the button to see if it is high or low
int sensorValue = 0; // value read from the pot
int outputValue = 0; // output value to the LCD and Servo
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
// tell arduino how many rows and collums lcd has
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Press The Button!");
randomSeed(analogRead(0));
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);
for (int i = 0; i < 5; i++){
Serial.println(stringHigh[i]);
delay(500);
}
for (int i = 0; i < 5; i++){
Serial.println(stringLow[i]);
delay(500);
}
if (outputValue == 0)
// if statement saying if the button is not pressed (0) then print one value
{ randNumber = random (stringHigh)
lcd.print (randNumber);
}else
// when button is pressed say this value
{randNumber = random (stringHigh)
lcd.print (randNumber);
}
//set the cursor to the first point on the lcd to display values
lcd.setCursor(0, 1);
}
it is telling me invalid conversation from char*** to long int