Hi,
Im a total novice when it comes to programming and I was wondering if anyone could help me.
I understand this is not a basic project (especially for a novice) but i like a challenge. The project uses a raspberry pi as a bridge for home kit. This sends requests over IP:port to the first Arduino (UNO) with an ethernet shield to process the commands. After the first Arduino process the command it is sent through Serial.print over the RX, Tx pins to this Arduino.
For this Uno I am trying to receive commands in through Serial then run them as a function. This arduino has 2 buttons (overrideButton, overrideOpen), one motor (on a shield) and an LED strip. I am able to control all 3 independantly.
After much research I have written this program:
#include <Stepper.h>
void setup() {
//arduino set up
Serial.begin(9600); //start serial
//ints
String serialInput = "";
int overrideButton = false; // turn override on
int overrideOpen = false; // open curtains while in override
bool openState = false; //check if open
int ambient = ""; //collection for sensor
const int stepsPerRevolution = 212; // motor revolution
int motorMove = 3800; //how far the motor has to move to flly close the curtain
int red = 0; //brightness out of 255
int green = 0; //brightness out of 255
int blue = 0; //brightness out of 255
Stepper myStepper(stepsPerRevolution, 8, 11, 12, 13);
myStepper.setSpeed(180);
//pins decleration
int sensor = A4;
int RX = 0;
int TX = 1;
int redbutton = 2;
int redPin = 3;
int blackButton = 4;
int greenPin = 5;
int bluePin = 6;
int motorPower = 7;
int motor1 = 8;
int motor2 = 9;
int motor3 = 10;
int motor4 = 11;
int motor5 = 12;
int motor6 = 13;
//pinmodes
pinMode(2, INPUT); //button
pinMode(3, OUTPUT); //redled
pinMode(4, INPUT); //button
pinMode(5, OUTPUT); //greenled
pinMode(6, OUTPUT); //blueled
pinMode(7, OUTPUT); //motorpower
pinMode(8, OUTPUT); //motorcontrol
pinMode(9, OUTPUT); //motorsheildpower
pinMode(10, OUTPUT); //motorsheildpower
pinMode(11, OUTPUT); //motorcontrol
pinMode(12, OUTPUT); //motorcontrol
pinMode(13, OUTPUT); //motorcontrol
}
void loop() {
while(bool !overrideButton) {
if (Serial.available() >0) {
while(Serial.available() > 0) {
String serialInput += (char)Serial.read();
delay(150);
}
}
Serial.print( int serialInput);
serialInput;
serialInput = "";
if (blackButton == HIGH) {
overrideButton = !overrideButton
}
}
}
while (bool overrideButton == true) {
if(blackButton == HIGH) {
overrideButton = !overrideButton
}
}
if (redButton == HIGH) {
overrideOpne = !overrideOpen
}
if (overrideOpen == true) {
curtainOpen();
} else if (curtainOpen == false) {
curtainClose();
} else {
for(int x = 0; x < 8; x++) {
Serial.print("ERROR ");
Serial.println("override function curtainopen not a bool!");
}
}
}
}
int curtainOpen() {
if (openstate == false) {
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
myStepper.step(motorMove);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
}
openState = true;
Serial.println("Curtains are open");
}
int curtainClose() {
if (openstate == true) {
digitalWrite(7, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
myStepper.step(-motorMove);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
}
openState = false;
Serial.println("Curtains are closed");
}
int led() {
digitalWrite(redPin, red);
digitalWrite(greenPin, green);
digitalWrite(bluePin, blue);
Serial.print(" Red = ");
Serial.print(red);
Serial.print(";");
Serial.print(" Green = ");
Serial.print(green);
Serial.print(";");
Serial.print(" Blue = ");
Serial.print(blue);
Serial.println(";");
}
int brightness() {
ambient = analogRead(sensor);
Serial.print("Sensor = ");
Serial.print(ambient);
Serial.println(";");
}
i have been having issues with all 3 sets of software, but this one is causing me the most grief. the compiler kicks out these errors:
HardwareArduino:59: error: expected primary-expression before 'bool'
while(bool !overrideButton) {
^
HardwareArduino:59: error: expected ')' before 'bool'
HardwareArduino:59: error: expected unqualified-id before '!' token
while(bool !overrideButton) {
^
HardwareArduino:154: error: expected '}' at end of input
}
^
exit status 1
expected primary-expression before 'bool'
Despite my best efforts i have not been able to clear these errors.
Thank you all in advance.