I am trying to create a cloud function that changes the brightness of LEDs for a project I am doing. When I compile, I get the error Compiler timed out or encountered an error
. When I comment out the particle function, all is well. Here is my code.
/*
* Project SUDSv2
* Description:
* Author:
* Date:
*/
//prototypes
int adjustBrightness(String command);
//Pins
//Output
int led = D1;
//Input
int leftInput = D3;
int rightInput = D2;
//variables
int brightness = 255;
// setup() runs once, when the device is first turned on.
void setup() {
Particle.function("adjustBrightness", adjustBrightness);
Serial.begin(12900);
Serial.println("Hello Serial!");
pinMode(led, OUTPUT);
pinMode(leftInput, INPUT);
pinMode(rightInput, INPUT);
analogWrite(led, brightness);
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
Serial.printlnf("Brightness: %d, Left: %d, Right: %d", brightness, digitalRead(leftInput), digitalRead(rightInput));
delay(500);
}
int adjustBrightness(String command){
if (brightness == command.toInt()) {
return 0;
}else{
brightness = command.toInt();
analogWrite(led, brightness);
return 1;
}
}