Hi @russdx,
As you pointed; I have converted the code to javascript.at the end It worked great :) Here is what I have done
var Pin0 = D1; var Pin1 = D2; var Pin2 = D3; var Pin3 = D4; var _step = 0; var boolean=true; var dir = true; function setup() { pinMode(Pin0, OUTPUT); pinMode(Pin1, OUTPUT); pinMode(Pin2, OUTPUT); pinMode(Pin3, OUTPUT); } function loop() { switch(_step){ case 0: digitalWrite(Pin0, LOW); digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); break; case 1: digitalWrite(Pin0, LOW); digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, HIGH); break; case 2: digitalWrite(Pin0, LOW); digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); break; case 3: digitalWrite(Pin0, LOW); digitalWrite(Pin1, HIGH); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); break; case 4: digitalWrite(Pin0, LOW); digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); break; case 5: digitalWrite(Pin0, HIGH); digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); break; case 6: digitalWrite(Pin0, HIGH); digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); break; case 7: digitalWrite(Pin0, HIGH); digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); break; default: digitalWrite(Pin0, LOW); digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); break; } if(dir){ _step++; }else{ _step--; } if(_step>7){ _step=0; } if(_step<0){ _step=7; } } setup(); var stepInterdal = setInterval(loop, 1);
@fobus started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi @russdx,
As you pointed; I have converted the code to javascript.at the end It worked great :)
Here is what I have done