-
• #2
That's great - thanks for posting up! It'll be really good to see how this turns out.
Where you're sending data, I don't think it matters what bytes you send at all (there's no
mosi
(output) pin specified so nothing will get sent anyway). Also you've set baud as 9500 - it's fine, but the chip itself seems to go up to 3000000, so you've got some headroom if you want to go a bit faster ;)Also, in Espruino you can just call
send
once to get an array of all your data, like:var d = SPI1.send(new Uint8Array(4 /* maybe you have 4 CD4014s */)); console.log(d[0].toString()); // etc etc
Might be a bit tidier.
-
• #3
It doesn't matter what you send - the data you send is sent out over the MOSI pin - you have only defined a miso pin, so that 0x00 or 0xwhatever that you send out isn't going anywhere. It doesn't have to, though. You're only "sending" something in order to cause it to run the sck pin to clock out the data.
Ugh, typed this hours ago, but by the time I saw I hadn't submitted it, Gordon had beaten me.
-
• #4
Ill do a little studying up on that Uint8Array. Thanks for the info!
-
• #5
Yeah, I think 9500 baud is excessively conservative. That's 1.1k bytes per second, or just under 1ms per byte....
Working on integrating a tool box for the work place that will provide some accountability to the user of the tool. The idea is to use the PICO, a MS146-2G Slot Reader (ID cards), a few magnetic holds and slew of TI CD4021BE. The drawers or cabinets will be locked by the magnetic holds, a user will use his ID card to gain access and remove tools from the drawer. Once closed the PICO will scan through and note what tools were removed. I plan to upload the information to a google spreadsheet with the ESP8266 of which I will build some code to send a text reminder to the users to return the tools at the end of the day. Here is the test code for the CD4021 so far.
if CD4021 gpio 1 is on return 1, if gpio 2 is on returns 10, 3-->100, all three on returns 111, etc.
Here is a diagram of how the chips are put together. Thanks to the work of the people at arduino.cc was I able to get this part together as some of this would be way over my head. Ill try to get some pictures on here as the project progresses. Thanks