International Alternative Energy Center
International Alternative Energy Center
Home | Profile | Register | Active Topics | Active Polls | Members | Private Messages | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?




 All Forums
 Technical Help and Questions
 Jig's, Coil winder jigs, Core molds/jigs and so on
 Arduino Microswitch counter code
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Electronix Hive
New Member


United Kingdom
49 Posts

Posted - January 01 2014 :  21:22:39  Show Profile  Visit Electronix Hive's Homepage Send Electronix Hive a Private Message  Reply with Quote
Hi all i thought i would share a code i wrote for the arduino micro controller and a microswitch controller for counting number of turns while winding coil
u can view counter on ur pc live as u wind if u dont have a small lcd screen




------Here is the code------

int state=LOW;
int lastState=LOW;
int count=0;
void setup(){
Serial.begin(9600);
pinMode(8, INPUT);
state=digitalRead(8);
}
void loop(){
delay(10);
if (state==HIGH && lastState==LOW){
count++;
Serial.println(count);
}
lastState=state;
state=digitalRead(8);
}



Happy Building EH

You must be logged in to see this link.


Edited by - Electronix Hive on January 01 2014 21:23:03
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
International Alternative Energy Center © 2000-2009 ForumCo.com Go To Top Of Page
This page was generated in 0.28 seconds. Snitz Forums 2000
RSS Feed 1 RSS Feed 2
Powered by ForumCo 2000-2008
TOS - AUP - URA - Privacy Policy
ForumCo Free Blogs and Galleries
Signup for a free forum or Go Banner Free