Show Posts
|
|
Pages: 1 [2] 3 4 ... 10
|
|
17
|
Forum 2005-2010 (read only) / Syntax & Programs / it no workie
|
on: March 27, 2009, 01:08:30 pm
|
|
//hooking up a numeric disp
int a = 2 int b = 3 int c = 4 int d = 5 int e = 6 int f = 7 int mi = 8
void setup(){ pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT); pinMode(mi, OUTPUT); }
void loop() { digitalWrite(e, HIGH); digitalWrite(c, HIGH); delay(2000); digitalWrite(e, HIGH); digitalWrite(c, LOW); digitalWrite(d, HIGH); digitalWrite(mi, HIGH); digitalWrite(a, HIGH); digitalWrite(b, HIGH); delay(2000); }
|
|
|
|
|
20
|
Forum 2005-2010 (read only) / Syntax & Programs / this wont work, why???
|
on: March 22, 2009, 12:01:40 pm
|
#include <Servo.h> Servo myservo; int ledPin = 13; // choose the pin for the LED int inputPin = 2; // choose the input pin (for a pushbutton) int val = 0; // variable for reading the pin status int pos = 0;
void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object // declare LED as output pinMode(inputPin, INPUT); // declare pushbutton as input }
void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH for(pos = 0; pos < 180; pos += 8) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } // turn LED OFF } else { for(pos = 180; pos>=1; pos-=8) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } }
its a function for my auto dog feeder
|
|
|
|
|