void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the both analog in values:
sensorValue1 = analogRead(analogInPin1);
sensorValue2 = analogRead(analogInPin2);
// map it to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 0, 255);
outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin1, outputValue1);
analogWrite(analogOutPin2, outputValue2);
// print the results to the serial monitor:
Serial.print("accelerometer X = " );
Serial.print(sensorValue1);
Serial.print("\t accelerometer Y = " );
Serial.print(sensorValue2);
Serial.print("\t output 1 = ");
Serial.print(outputValue1);
Serial.print("\t output 2 = ");
Serial.println(outputValue2);
// wait 10 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(10);
}