#include "picsys18.h"

void
setup()
{
	pinMode(SOUNDER, OUT_BEEP) ;
	
	SEG7_init(SR_DAT, SR_CLK, SEG1, SEG2, SEG3, SEG4) ;
}

void
loop()
{
	int v ;
	
	v = analogRead(PHOTO_SENSOR) ;
	
	SEG7_write(v, SEG7_INT) ;
	
	if (v > 512) {
		analogWrite(SOUNDER, 8) ;
	} else if (v > 128) {
		analogWrite(SOUNDER, 7) ;
	} else if (v > 64) {
		analogWrite(SOUNDER, 6) ;
	} else if (v > 32) {
		analogWrite(SOUNDER, 5) ;
	} else {
		analogWrite(SOUNDER, 0) ;
	}
	
	delayMilliseconds(100) ;
}
