arduino-course/Week 3/Relay-Motor/Relay-Motor.ino

20 lines
309 B
Arduino
Raw Permalink Normal View History

2019-11-22 19:11:28 +01:00
long val;
int spin;
void setup() {
Serial.begin(9600);
Serial.println("Trolaso");
}
void loop() {
val = analogRead(A0);
Serial.println("valor: ");
Serial.println(val);
spin = map(val, 0, 1023, 0, 255);
analogWrite(9, spin);
Serial.println("giro: ");
Serial.println(spin);
delay(500);
}