SparkFun Forums 

Where electronics enthusiasts find answers.

Search found 2 matches

 Go to advanced search

Re: convert Character string into binary

 by buxtronix ¦  Thu Oct 06, 2011 3:00 am ¦  Forum: Code ¦  Topic: convert Character string into binary ¦  Replies: 2 ¦  Views: 2527

For Arduino (you can adapt to your need if pure avr):

Code: Select all
void setup() {
  Serial.begin(9600);
  char *str = "0123";
  for (char *c = str ; *c ; c++)
    for (char b = 7 ; b > -1 ; b--)
      Serial.print((*c >> b) & 0x1 ? "1" : "0");
}

void loop() {
}

Re: Arduino + rotary encoder

 by buxtronix ¦  Thu Oct 06, 2011 2:49 am ¦  Forum: Code ¦  Topic: Arduino + rotary encoder ¦  Replies: 8 ¦  Views: 40185

Resurrecting this thread again, as my recent need for one led me to do some useful stuff.. The main issue with a lot of these routines is that they are susceptible to switch contact bounce, and can give spurious output. I looked for a lot and didn't come up with much (just a lot of routines with deb...