-
I've been think about a reed switch as it doesn't rely on outside light but I'm not sure if the magnet will be close enough to activate it. Because the doors overlap the magnet would be about 70mm away. I might buy it anyway to try.
I'll try the cylinder cup idea. Simplest solutions are normally the best.
I tried have conditional values to turn the light on and off but this led to rave like effects where the lights would randomly turn on/off and not turn on/off depending on the room light.
The IR sensor would be great but a little more costly I'd guess.
I'll let you know how each option goes.
-
Hello,
I've installed LED strips in my wardrobe and using Espruino and a Photoresistor the LEDs turn on of off when the door is opened/closed. All the wiring and code works perfect, the issue I have is more funny.
Wardrobe door opens and sun/room light hits the photoresistor, Espruino reads this and turns on the LEDs. All good so far.
The problem is when the doors close. The LEDs light up the inside so much the photoresistor doesn't detect a large enough drop in light to turn off the LEDs. :(I've tried many different light values and code to guess when the door is closed but every fix has side effects. Should I try looking at using some other sensor to detect the doors opening/closing? Reed switch, motion sensor, ...
My wardrobe has two sliding doors that over lap making it a little awkward. -
I've tried all the of the different AmbiBox outputs, most of them sent data down the COM port but Espruino still only receives the same unreadable text.
I saw this pattern that appear to be the beginning of each line but I'm not sure how to use that to split up the data and then decode it.Ada\x00\x03V
I again tried the example here http://www.espruino.com/USART using this new line breaker but it is still unreadable:
Vª²»«³¼®·¿°·¿
I'm not sure why to try next?
-
Hey Gordon,
Working with USB and Bluetooth is working well. Serial1.setConsole(); was the trick.
Now the PC is sending data to Espruino and I can read it over Bluetooth but I'm not sure what encoding it's in? I've tried many options of toString() parseInt() and reading the Hex in a Hex decoder. Below is a sample of the data I'm getting and I've attached a large file with more that Espruino saved to the SD card.
Do you know what format this is in and how to decode it?ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3 ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3 ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3ô/,,+3
Running this through ([http://frhed.sourceforge.net] Frhed Hex editor) I get something more readable but I'm still not sure what format it is in:
<bh:00><bh:f4><bh:11><bh:1f>/<bh:10><bh:1d>,<bh:10><bh:1d>,<bh:11><bh:1c>+3 <bh:00><bh:f4><bh:11><bh:1f>/<bh:10><bh:1d>,<bh:10><bh:1d>,<bh:11><bh:1c>+3 <bh:00><bh:f4><bh:11><bh:1f>/<bh:10><bh:1d>,<bh:10><bh:1d>,<bh:11><bh:1c>+3
-
Still nothing I'm afraid. Is it possible to send data to Espruino while watching it in the IDE over bluetooth?
To give you some more info on what I'm trying to do, my goal is to use Espruino as the controller for a TV Ambilight system. The software on the PC is AmbiBox (http://www.ambibox.ru/en/index.php/Main_Page) it analyse whatever is on the PC screen into colour blocks and send it over serial port to Espruino which will then control an RGB LED strip.
-
Hello,
How do I go about reading Serial data coming from a PC via USB and write that to the SD card?
I've tried the code below but nothing gets written to data.txt and LED2 doesn't flash.function onInit() { digitalWrite(LED2,1); var cmd=""; var fs = require("fs"); Serial1.setup(9600/*baud*/); Serial1.on('data', function () { digitalWrite(LED2,0); cmd+=data; var idx = cmd.indexOf("\r"); while (idx>=0) { var line = cmd.substr(0,idx); cmd = cmd.substr(idx+1); var s = "'"+line+"' = "+eval(line); idx = cmd.indexOf("\r"); fs.appendFile("data.txt", s+"\r"); } digitalWrite(LED2,1); }); }
-
Hi Gordon,
That interval loop is very similar to what I wrote before, wonder why it didn't work then. Bad chip I think, I bought 5 off eBay and only 2 of them work correctly.
I fixed the static noise by powering Esruino from the wall rather than the PC.Thanks everyone for you help, I've now got a kickass graphic visualizer. Here is a quick videos of it in action: http://youtu.be/oADZs-v-OUE
(the code)
If you'd like Gordon, I'd love to write a tutorial on making one for your site. -
-
@DrAzzy it is yes.
When I connect the 5V to the matrix I often see some of the pixels randomly flash on in one of(red/green/blue) one only for a fraction of a second and then everything goes back to off. -
Something that could have caused it. It was all wired up correctly and working in the PIN stated above and while turned on I unplugged the matrix GND/5V from Espruino and plugged them directly into a 5v 0.5A wall adaptor .
Now I've gone right back to basics and just trying to get it to work again on Espriuno.I don't power is the problem as I can power the matrix from either Arduino/Espruino/5v adaptor including the controller it's self. So it has to be something to do with the B15 data out? But if so then why does the WS2812 strip work Ok on B15?
It's is becoming a real mystery.
-
-
Hello,
My RGB123 16x8 matrix was working perfectly and for no reason it's just stopped?
The wiring is: GND => GND, DIN => B15, 5V =>BAT
I've copied the code from here: http://www.espruino.com/RGB123
But nothing happens, every pixel stays off?..I've tried debugging the following:
Matrix is broken? NO. I've tried it on an Adruino and it works fine. I can even power the matrix from Espruino while sending data from adruino and that works. So it must be something to do with the data being sent from B15?..Pin B15 is broken? NO. I can use a WS2812 strip on pin B15 and they work fine
Some wrong with Espruino? don't think so as I've tried on my second espruino and same results?.
Any ideas what I should try next? this is driving me mad.
-
SUCCESS!
Using DrAzzy's delay() I've got it working! http://pastebin.com/jw361rcN
The only thing I'm confused about is if I leave the music on mute I see random small flashes on each band from time-to-time. If I wire up my headphones the wrong way around I can hear the static noise from the chip and/or Espruino which match the random flashes perfectly. Any ideas what this could be and how to stop it? Everything is grounded on the Espruino via a breadboard, not sure if this is the cause and solution. -
-
I've fixed the crash, it was because I was re-declaring loop each time rather than once and then overriding it.
I understand analogRead returns values between 0-1 but the values I get are so low I tihnk it's just background static. Changing the audio-in volume should change values at least.
As DrAzzy suggested I don't have a delay after the read so I'll implement that this evening and let you know if it works. -
Hello,
I've bought a MSGEQ7 chip (https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf) and wired it up following this http://nuewire.com/info-archive/msgeq7-by-j-skoba/See my wiring here: http://i.imgur.com/jUXKgNn.jpg?2
I ported the following code from the same tutorial:var strobe = B8, // strobe pins on digital B8 res = B9, // reset pins on digital B9 audioIn = A0, // DC out from MSGEQ7 chip levels = Array(), band=0; function onload() { digitalWrite(strobe, LOW); digitalWrite(res, LOW); } onload(); function readMSGEQ7() { // Reset chip digitalWrite(res, HIGH); digitalWrite(res, LOW); band = 0; var loop = setInterval(function(){ digitalWrite(strobe, LOW); // Get outputted value and store it levels[band] = analogRead(audioIn); digitalWrite(strobe, HIGH); // Stop after 7 loops band++; if(band >= 7) { clearInterval(loop); } }, 0.04); // 40 microseconds } function tick(){ readMSGEQ7(); // Debugging console.log(levels[0] + '-' + levels[1] + '-' + levels[2] + '-' + levels[3] + '-' + levels[4] + '-' + levels[5] + '-' + levels[6]); } setInterval(tick, 1000);
The console.log() output looks like this: http://pastebin.com/DVMBQQ4Z
All of the numbers are very low and they don't seem to change when I in-decrease the volume or mute completely. After a few seconds it crashes but I think that's more to do with the console.log getting too big.With the same wiring on Arduino and the code from the tutorial it seems work correctly, outputting higher/lower values depending on the music playing or not at all.
This makes me think it must be the JS code. Can you see any issues with it? I'm a little unsure about my use of the delayed loop to poll the chip but without a microdelay function I'm not sure how else to do it.
Any help you can offer would be great.
Thanks -
-
-
Hi Gordon,
The new Espruino update has fixed the 'print()' bug but sadly it's still not working for me. I don't get any code errors the display just shows the first row fully blocked and nothing on the second row (see photo below). It is always like this from the moment I plug it in.
Have I wired something up incorrectly? Here are the pins I'm using:
var lcd = require("HD44780").connect(A8,A9,A10,A11,A0,A1);
Any ideas? Is this a code/hardware/wiring issue?
-
Do you know any good FFT libraries in JavaScript?
Would it be worth looking into a hard solution for the audio analysing?
I'm very new to electronic but I found this chip which might help, MSGEQ7.
Or maybe an Arduino shield, https://www.sparkfun.com/products/10306 -
-
Hi Gordon,
I'm only using the unminifed code from your code example, does espruino minify it on the fly?
I tried putting all of the module code into the IDE, like this: http://pastebin.com/MatnNmhYERROR: Got ':' expected '(' at line 15 col 12 print : function(str) { ^ ERROR: Got function expected ':' at line 15 col 14 print : function(str) { ^ at line 15 col 21 print : function(str) { ^ in function "hd44780" called from line 1 col 26 ERROR: Using '.' operator on non-object at line 1 col 4 led.print("Hello World!"); ^ =undefined
It looks like a syntax error but there is nothing wrong with it? Any ideas what I should try next?
-
Hi guys,
I've got a HD44780 LCD character Display Module and I'm trying to get it working with Espruino. I've followed the guide here http://www.espruino.com/HD44780 and installed the HD33780 module, but whenever I run the code I get the following error:// My code var lcd = require("HD44780").connect(A4,A5,A0,A7,A2,A3); lcd.print("Hello World!");
// Error returned >echo(0); ERROR: Got ':' expected '(' at line 1 col 94 {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);a(1,1);return{write:a,clear:function(){a(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.charAt(c)))},cursor:function(b){a(b?15:14,1)},setCursor:function(b,c){a(128|[0,64,20,84][c]+b,1)},createChar:function(b,c){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}} ^ ERROR: Got function expected ':' at line 1 col 95 {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);a(1,1);return{write:a,clear:function(){a(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.charAt(c)))},cursor:function(b){a(b?15:14,1)},setCursor:function(b,c){a(128|[0,64,20,84][c]+b,1)},createChar:function(b,c){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}} ^ at line 1 col 102 {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);a(1,1);return{write:a,clear:function(){a(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.charAt(c)))},cursor:function(b){a(b?15:14,1)},setCursor:function(b,c){a(128|[0,64,20,84][c]+b,1)},createChar:function(b,c){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}} ^ in function "HD44780" called from line 1 col 185 in function "connect" called from line 1 col 55 ERROR: Using '.' operator on non-object at line 1 col 4 lcd.print("Hello World!"); ^ =undefined >
Do you have any idea what's going wrong here? I've tried writing the module code directly but I get much the same results. What should I try next to fix this?
Thanks
Update: I've got it working with IR proximity sensors. It's not 100% perfect as the overlapping door is a little bit too far away to get accurate readings and bright sunlight can affect the readings. But I think I can correct it with code modifications.
If I where to do this project again I think I would try with some coiled spring switches like: http://tinyurl.com/ountcx4