mirror of
https://github.com/KevinMidboe/Arduino.git
synced 2025-10-29 09:30:12 +00:00
26 lines
478 B
C++
26 lines
478 B
C++
#include <Servo.h>
|
|
|
|
Servo myservo;
|
|
|
|
int potpin = 0;
|
|
int potReading;
|
|
int photocellPin = 1;
|
|
int photocellReading;
|
|
|
|
void setup()
|
|
{
|
|
myservo.attach(9);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
potReading = analogRead(potpin);
|
|
potReading = map(potReading, 0, 1023, 0, 179);
|
|
myservo.write(potReading);
|
|
photocellReading = analogRead(photocellPin);
|
|
|
|
int thisPitch = map(photocellReading, 1, 1000, 120, 1500);
|
|
tone(8, thisPitch, 10);
|
|
delay(1);
|
|
}
|