#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
unsigned int top = 100;
void setup() {
// add external voltage (Javascript) with name "pin n" to access output pins
pinMode(9, OUTPUT);
pinMode(6, INPUT);
// Clear interrupts
cli();
// Reset TCCR1B from Arduino meddeling
TCCR1B = 0;
// Set fast PWM Mode with Top value as a frequency controller
TCCR1A |= (1 << WGM10) | (1 << WGM11);
TCCR1B |= (1 << WGM12) | (1 << WGM13);
// Set toggle on compare match
TCCR1A |= (1 << COM1A0);
// Set TOP value which will reflect period length between 0 to 65536
OCR1A = 200;
// Set prescaler to 1 and start PWM
TCCR1B |= (1 << CS10);
// Enable global interrupts
cli();
}
void loop() {
while (1) {
int v_out;
v_out = digitalRead(6);
delay (1);
}
}