Hi
The editor software suggested I report the failure of compilation on this forum so that's what I am doing. Previous versions compiled ok so I am at a loss to explain why this one went wrong. Any ideas? I was messing around with my if stuff for PWM2.
program code follows=========
/*
digital input, analog output, serial output
Reads a digital input pin, uses the result to increment a value that is then
used to set the pulse width modulation (PWM) of an output pin.
Also prints the results to the Serial Monitor.
The circuit:
- input "generator stopped" signal on pin 3
- LED connected from digital pin 9 to ground
*/
int PWM = 0; // value output to the PWM (analog out)
int PWM2 = 0; // value output to second stage diversion
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(3, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
// check if dumping enabled and not inhibited
if (digitalRead(3)) {PWM++ ; digitalWrite(13, HIGH);}
else {PWM-- ; digitalWrite(13, LOW);}
if (PWM>255) {PWM=255;PWM2++;}
else PWM2--;
if (PWM<0) PWM=0;
if (PWM2<0) PWM2=0;
// change the analog out value:
analogWrite(9, PWM);
analogWrite(10, PWM2);
// print the results to the Serial Monitor:
Serial.print("PWM = ");
Serial.print(PWM);
Serial.print("\t PWM2 = ");
Serial.println(PWM2);
// wait a second before the next loop for the venus device
// to catch up after the last change of load:
delay(1000);
}
======
thanks
Hugh