i have code made me
quote
#include <irremote.h>and want when case 4294967295 this
#include <servo.h>
#define in1 4
#define in2 5
#define in3 6
#define in4 7
int steps = 0;
boolean direction = true;// gre
unsigned long last_time;
unsigned long currentmillis ;
int steps_left=4095;
long time;
int irpin = 11;
int pos = 0;
servo servo1;
irrecv irrecv(irpin);
decode_results results;
void setup()
{
serial.begin(9600);
irrecv.enableirin();
servo1.attach(9);
pinmode(in1, output);
pinmode(in2, output);
pinmode(in3, output);
pinmode(in4, output);
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume();
}
if (results.value == 1)
{
irrecv.resume();
}
switch(results.value)
{
case 16712445
:
{
for(pos = 0; pos < 180; pos += 1)
{
servo1.write(pos);
delay(15);
break;
}
break;
}
case 16761405:
{
for(pos = 180; pos>=1; pos-=1)
{
servo1.write(pos);
delay(15);
break;
}
break;
}
case 4294967295:
{
}
}
}
quote
/*how do?
byj48 stepper motor code
connect :
in1 >> d8
in2 >> d9
in3 >> d10
in4 >> d11
vcc ... 5v prefer use external 5v source
gnd
written :mohannad rawashdeh
http://www.instructables.com/member/mohannad+rawashdeh/
28/9/2013
*/
#define in1 8
#define in2 9
#define in3 10
#define in4 11
int steps = 0;
boolean direction = true;// gre
unsigned long last_time;
unsigned long currentmillis ;
int steps_left=4095;
long time;
void setup()
{
serial.begin(115200);
pinmode(in1, output);
pinmode(in2, output);
pinmode(in3, output);
pinmode(in4, output);
// delay(1000);
}
void loop()
{
while(steps_left>0){
currentmillis = micros();
if(currentmillis-last_time>=1000){
stepper(1);
time=time+micros()-last_time;
last_time=micros();
steps_left--;
}
}
serial.println(time);
serial.println("wait...!");
direction=!direction;
steps_left=4095;
}
void stepper(int xw){
(int x=0;x<xw;x++){
switch(steps){
case 0:
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, high);
break;
case 1:
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, high);
digitalwrite(in4, high);
break;
case 2:
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, high);
digitalwrite(in4, low);
break;
case 3:
digitalwrite(in1, low);
digitalwrite(in2, high);
digitalwrite(in3, high);
digitalwrite(in4, low);
break;
case 4:
digitalwrite(in1, low);
digitalwrite(in2, high);
digitalwrite(in3, low);
digitalwrite(in4, low);
break;
case 5:
digitalwrite(in1, high);
digitalwrite(in2, high);
digitalwrite(in3, low);
digitalwrite(in4, low);
break;
case 6:
digitalwrite(in1, high);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, low);
break;
case 7:
digitalwrite(in1, high);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, high);
break;
default:
digitalwrite(in1, low);
digitalwrite(in2, low);
digitalwrite(in3, low);
digitalwrite(in4, low);
break;
}
setdirection();
}
}
void setdirection(){
if(direction==1){ steps++;}
if(direction==0){ steps++; }
if(steps>7){steps=0;}
if(steps<0){steps=7; }
}
well, can first start putting code code tags...
Arduino Forum > Using Arduino > Programming Questions > need help with code (n00b alert!!!)
arduino
Comments
Post a Comment