byte to array, or maybe a string?


greetings!  apologize, has been many years since programming classes, have forgot of syntax.  trying should quite easy. using 595 shift register 8 relays, serial.read 0-7 or 1-8 control relays... can have them start off , each key press turns on corresponding relay, or start them on , serial data turns them off...  thinking need convert int "keypressed" binary array (8bits of 0 or 1), simple loop i=bit want change, compare existing bit if 0 set 1 else set 0.  see examples loop i++, setting each bit array#1, 2 3 etc... seems bulky me , have small , clean

int relaystates
byte relaystatesarray [8]
serial.read (x)
cannotfindcommantoconvertinttoarray
if relaystatesarray[x]=0
relaystatesarray[x]=1
else relaystatesarray[x]=0
int relaystates=relaystatesarray
shiftout relaystates

i have read sooooo many tutorials on shiftout, cannot find showing how control on , off of individual pins
tia

quote
and each key press turns on corresponding relay
each key press on what?

quote
cannotfindcommantoconvertinttoarray
that's because array collection of objects , int 1 object.


Arduino Forum > Using Arduino > Programming Questions > byte to array, or maybe a string?


arduino

Comments