ClearMemory041063
Member since Apr 2016 • Last active Jun 2018Most recent activity
-
-
-
- 1 comment
- 1,959 views
-
Light Seeking System
Two photo resistors are positioned on opposite sides of a rectangular beam. It the beam is pointing at a light source both photoresistors produce equal values. If not aligned this balance is upset by the shadow of the beam and the difference in photo resistor output is used to rotate the beam using a stepper motor.
Gnd-- 10k--AnalogInPin--Photoresistor--3.3V
The code
//SeekSun1.js // 7 Mar 2017 // add stepper motor code // 4 Mar 2018 // Uses 2 photoresistors and 10k resistors to provide // two analog inputs // the LED color changes depending on the sign of the // difference between the analog inputs. // // | // pr1----|====pr2 // the vertical bar casts a shadow on the pr // this creates a difference in input values // use this to rotate the assembly so that the // difference in inputs is within the band // Stepper Motor Interface Configuration var action=0; var Step=A8;//LED1;//A8; var Dir=B7; var pp=new Uint8Array(32); // 16 microsteps *2, see BigEasy docs // Photo resistor Configuration var P1=B1; var P2=A7; pp.fill(1); //pulse time in ms pinMode(Step,"output"); pinMode(Dir,"output"); digitalWrite(Step,0); digitalWrite(Dir,0^action); clearInterval(); function move(d){ digitalWrite(Dir,d^action); digitalPulse(Step,0,pp); } var verbose=1;//0;//1; function clog(a){ if(verbose>0)console.log(a); } var band=0.01; pinMode(P1,'analog'); pinMode(P2,'analog'); clog(analogRead(P1)); clog(analogRead(P2)); var a,b,c,d; var sss=""; setInterval(function(){ a=analogRead(P1); b=analogRead(P2); sss=a.toString()+","; sss+=b.toString()+","; sss+=(a-b).toString(); clog(sss); c=a-b; d=c; if(d<0)d=d*-1; if(d<band){ digitalWrite(LED2,0); digitalWrite(LED1,0); //nomotion(); }else{ if(c<0){ digitalWrite(LED1,0); digitalWrite(LED2,1); //rotleft(); move(0); } if(c>0){ digitalWrite(LED2,0); digitalWrite(LED1,1); //rotright(); move(1); } }//end else },1000);
Stepper Motor Stuff
or
BigEasy2or for smaller stepper motors
EasyDriverWiring
Pico Bigeasy
Gnd Gnd
B7 Dir
A8 Step
Powered the BigEasy board with 12V
-
If you use console.log in a program but disconnect the program execution is blocked when the console buffer is full.
For example:
// Console.log blocks LED On/Off flashing when // disconnected var l=0; myinterval=setInterval(function () { digitalWrite(LED1,l=!l); }, 1000); var i=0; setInterval(function(){ console.log(i); i++; },200); // load program // LED is pulsing On an dOff // Console is displaying the count in i // Disconnect the WebIde // The LED action stops // Reconnect the WebIde // Buffered count is displayed // LED resumes action
and the output:
|_| http://espruino.com 1v95 Copyright 2017 G.Williams > =undefined 0 1 2 3 4 5 6 7 8 9 10 11 Disconnected ( the LED stops until reconnected) > 12 13 14 15 16
If you are using console.log to show the connection status etc. of a WiFi connection, disconnecting the WebIde will block the server.
Not complaining about this, just posting to let others know about this gotcha.
-
- 3 comments
- 2,789 views
Retired. Just having fun now.
I'm running an Espruino Board connected to ESP8266 via serial port.
Working on a program derived from the SD card file server example.
When you request a file from the displayed list, it looks at the file extension and modifies the MIME header field.
This causes files with the extension .HTML to load the Web page.
Files with the extension .js allow an .HTML file to include scripts.
Files with the extension .csv cause Excel to load the file into a spreadsheet, which can be saved on your hard drive.
I'm having problems with another part that accepts POSTs from a client.