hello,
My aim is todo like the following,
send some bits like "01001010" zero stands for off and 1 for on and every bit is responsible for an led.
For example i send "00000000" now all leds are off else if "11111111" all leds are on, but the trick here is "0110101" so the first led is off the second and third in on then the 4th is off and the 5th is on.....etc...
any ideas on how the code can be writen?
those are just 8 bits, also does the arduino has any limitations if i did the same but with 80 bits?
CrossRoads:
Why 8 bytes? Just send 1 byte with the eight 0 or 1 bits. Then just send 10 bytes total. Much faster.
oh i am very sorry i mixed the names , let me fix that.
so i would send 10 bytes every byte has 8 bits, so if i type a whole sequence which contains 80 bits like:"01......10" the arduino will translate those to 10 bytes rrite?
The data is coming serially from another device? Then yes, just receive 10 bytes and do what you will with it - like shift into 10 shift registers that drive the LEDs.
You send the Arduino the ASCII character for your led on/off condition.
Then in the Arduino you create a loop to read each bit in the character and respond accordingly.
Numbers are in binary.
.
CrossRoads:
The data is coming serially from another device? Then yes, just receive 10 bytes and do what you will with it - like shift into 10 shift registers that drive the LEDs.
so do you have any ideas onto how to do that in code?
let me tell you what i want to do,
i have 10 arduinos every arduino has 8 leds and another master arduino that sends 80 bits of 0 and 1, so for example i want to turn on led 34 so the arduino searches until it reaches bit number 34 and sees if its 0 or 1.
LarryD:
You send the Arduino the ASCII character for your led on/off condition.
Then in the Arduino you create a loop to read each bit in the character and respond accordingly.
Numbers are in binary.
.
ok same idea but you say that instead of 80 bits we will just send 8 Characters"bits" which will be converted later into the arduino, you made it easier but how to tell the arduino that bit 5 in the decoded ASCII charachter"which is among other 8 chrachters which means that the arduino needs to know which ASCII bit to work on" is linked to led number 13 for example.
Can u understand anything? XD
digitalWrite (ssPin, LOW); // ssPin is D10
for (x=0; x<10; x=x+1){
SPI.transfer(ledArray[x]); // SCK D13 to SRCLK, MOSI D11 to serial data in, daisy chain serial data out
}
digitalWrite (ssPin, HIGH); // all outputs update on this rising edge
CrossRoads:
Why 10 arduinos? 10 shift registers would do.
digitalWrite (ssPin, LOW); // ssPin is D10
for (x=0; x<10; x=x+1){
SPI.transfer(ledArray[x]); // SCK D13 to SRCLK, MOSI D11 to serial data in, daisy chain serial data out
}
digitalWrite (ssPin, HIGH); // all outputs update on this rising edge
bec the arduinos will be in different far places so there is no way to add shift registers
Send two bytes.
1st byte identifies the Arduino.
2nd byte is the on/off condition
Example:
send 5 then F
this would mean Arduino #5 has a F (46 hex or 01000110 binary)
thats not what i want but ok lets go with that, so the next step how to link every bit with an led after the arduino has received its ASCII and converted it?
ok great thats nearly what i want but like this: so PORTD = 0d01001010 but i want to replace "0d01001010" to the values recived from the serial, so it will be PORTD = values which will be identified at the beginning as "int values = Serial.Read()" am i going in the right path now?