forked from luon/wordclock
41 lines
582 B
C++
41 lines
582 B
C++
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <avr/interrupt.h>
|
|
#include <avr/io.h>
|
|
|
|
#define LEDPIN 13
|
|
#define FOTOTRANSITORPIN 0 // fototransistor is on analog 0
|
|
|
|
void setup()
|
|
{
|
|
analogReference(INTERNAL1V1);
|
|
pinMode(LEDPIN, OUTPUT);
|
|
Serial.begin(115200);
|
|
}
|
|
|
|
void loop(void)
|
|
{
|
|
int n;
|
|
int v;
|
|
|
|
for (n = 0; n < 9; n++)
|
|
{
|
|
if (n == 8)
|
|
analogWrite(LEDPIN, 255);
|
|
else
|
|
analogWrite(LEDPIN, 1 << n);
|
|
Serial.print("n: ");
|
|
Serial.print(n);
|
|
Serial.print(", ");
|
|
|
|
v = analogRead(FOTOTRANSITORPIN);
|
|
Serial.print("v: ");
|
|
Serial.println(v);
|
|
delay(200);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|