Pages: [1]   Go Down
Author Topic: LED program need help!!!!  (Read 303 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Right for a project i am trying to control 5 LED's using VB. I have the VB code done and it creates a 5bit binary number that i am able to pass to arduino.

What i want to know is how do i split this string up into the separate bits so that i can process each one (which i know how to do)
« Last Edit: February 28, 2013, 08:23:54 pm by TheSpook » Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Walking through bits can be done with bitRead(), http://arduino.cc/en/Reference/BitRead
But you have to convert the serial data to a integer (or a byte).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for fast reply ill give that a go smiley-grin
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right iv got it reading the separate bits but how do i reference the bitRead?

p.s. very new to arduino
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3360
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right iv got it reading the separate bits but how do i reference the bitRead?

p.s. very new to arduino

Depends on what you mean by "reference the bitRead".

You call the bitRead with something like this:

Code:
byte someBit = bitRead(someNumber, someBitPositionInTheNumber);
Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2202
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Or use bitwise and http://arduino.cc/en/Reference/BitwiseAnd.

Mark
Logged

Pages: [1]   Go Up
Jump to: