Skip to content

Instantly share code, notes, and snippets.

@tomoyo-kousaka
Created May 31, 2011 11:39
Show Gist options
  • Save tomoyo-kousaka/1000361 to your computer and use it in GitHub Desktop.
Save tomoyo-kousaka/1000361 to your computer and use it in GitHub Desktop.
tokeiEx(Arduino
int sensorPin = A0;
int val = 0;
int ledPin = 13;
int sensorValue = 0;
float times = 0;
int send;
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
pinMode(13,OUTPUT);
}
void loop() {
val = digitalRead(2); // read input value
int sensorValue = analogRead(A0);
times = ((sensorValue-100)/14.5);
if(times<0)times=0;
else if(times>60)times=60;
Serial.println(times,BYTE);
if(val == HIGH){
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment