I can't mess with the CS code. 

Sent from a mobile device.

> On Dec 10, 2014, at 11:48 AM, Brian Richardson <[email protected]> wrote:
> 
> I think you want to change the lines like this:
> if ((pressBytes[row] | 32) == 32)
> 
> to this:
> 
> if ((pressBytes[row] & 32) == 32)
> 
> 
> 
>> On Wed, Dec 10, 2014 at 11:45 AM, Thomas Hudson <[email protected]> wrote:
>> Hey All,
>> 
>> There is some code written in C-sharp. I'm wondering how to serial output to 
>> this program. I'm pretty close but can't figure it out.  Any help?
>> 
>> CS code: 
>>        private Floor floor;
>> 
>>         private int rowCount { get { return 13; } }    //there are 13 rows 
>> of buttons
>> 
>>         private int columnCount { get { return 8; } }
>> 
>>         private void DoIOCircuit()
>>         {
>>             byte headerByte = 33;   // exclamation point
>>             byte[] headerByteArray = { 33 };  // exclamation point "!" is 33 
>> in ASCI
>> 
>> 
>>             // read buttton presses
>>             int bytesExpected = rowCount + 1;
>>             byte[] pressBytes = new byte[bytesExpected];
>>             if (serialPort.Read(pressBytes, 0, bytesExpected) != 
>> bytesExpected)
>>             {
>>                 throw new System.IO.IOException();
>>             }
>>             // check header byte
>>             if (pressBytes[0] == headerByte) // its looking for the "!" for 
>> the 1st byte
>>             {
>>                 RaiseEventsForPressBytes(pressBytes);
>>             }
>> 
>>         }
>> 
>>         private void RaiseEventsForPressBytes(byte[] pressBytes)
>>         {
>>             for (int row = 0; row < rowCount; row++)
>>             {
>>                 if ((pressBytes[row] | 128) == 128)   //I guess this is 
>> looking for a 1 or a zero for each bit
>>                     floor.RaiseTileEvents(0, row);
>>                 if ((pressBytes[row] | 64) == 64)
>>                     floor.RaiseTileEvents(1, row);
>>                 if ((pressBytes[row] | 32) == 32)
>>                     floor.RaiseTileEvents(2, row);
>>                 if ((pressBytes[row] | 16) == 16)
>>                     floor.RaiseTileEvents(3, row);
>>                 if ((pressBytes[row] | 8) == 8)
>>                     floor.RaiseTileEvents(4, row);
>>                 if ((pressBytes[row] | 4) == 4)
>>                     floor.RaiseTileEvents(5, row);
>>                 if ((pressBytes[row] | 2) == 2)
>>                     floor.RaiseTileEvents(6, row);
>>                 if ((pressBytes[row] | 1) == 1)
>>                     floor.RaiseTileEvents(7, row);
>>             }
>>         }
>> 
>> 
>> Here's my Arduino code:
>> 
>> void loop() {
>>    
>>    
>>     Serial.write(33);    // "!" in ASCII
>>     Serial.write(1);     //row 1   00000001
>>     Serial.write(16);   //row 2  00010000
>>     Serial.write(1);    // row 3
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>>     Serial.write(1);
>> 
>> 
>> 
>> 
>> -- 
>> Thomas Hudson, PE
>> thomashudson.org
>> 1035 NE Skidmore Street
>> (503) 522-9069
>> 
>> 
>> _______________________________________________
>> dorkbotpdx-blabber mailing list
>> [email protected]
>> http://music.columbia.edu/mailman/listinfo/dorkbotpdx-blabber
> 
> _______________________________________________
> dorkbotpdx-blabber mailing list
> [email protected]
> http://music.columbia.edu/mailman/listinfo/dorkbotpdx-blabber
_______________________________________________
dorkbotpdx-blabber mailing list
[email protected]
http://music.columbia.edu/mailman/listinfo/dorkbotpdx-blabber

Reply via email to