int pirosLed = 11;
int poti = A0;
int buzzer = 8;
int photo = A1;
int photoPos;
int potiPos;
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
pinMode(pirosLed, OUTPUT);
pinMode(poti, INPUT);
pinMode(photo, INPUT);
potiPos =-1;
photoPos = analogRead(photo);
Serial.print("fényérték: ");
Serial.println(photoPos);
}
void loop() {
// put your main code here, to run repeatedly:
//digitalWrite(pirosLed, HIGH);
//delay(200);
//for (int i = 0; i <= 255; i++) {
// analogWrite(pirosLed, i);
//delay(10);
//}
if (potiPos != analogRead(poti)){
potiPos = analogRead(poti);
Serial.print("Poti érték: ");
Serial.println(potiPos);
Serial.print("Analóg jelérték: ");
Serial.println(potiPos/4);
analogWrite(pirosLed, potiPos/4);
tone(buzzer, potiPos*10, 100);
}
if (photoPos != analogRead(photo)){
photoPos =analogRead(photo);
Serial.print("Fényérték: ");
Serial.println(photoPos);
analogWrite(pirosLed, photoPos/4);
}
//delay(200);
}