Loading...
Pages: [1]   Go Down
Author Topic: Trying to use binary number (B10000) in lib and getting error.  (Read 183 times)
0 Members and 1 Guest are viewing this topic.
Manchester, New Hampshire
Offline Offline
Edison Member
*
Karma: 0
Posts: 1120
Propmaker
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried to use PORTB &= ~B10000; in WaveHC.cpp and I get "B10000 not declared in this scope".  Do I have to include some library to use these constants?  Which one?

Also, it can't find the SPI library either.  How do I specify the include for that?  #include <SPI.h> doesn't work.
Logged

Sydney
Offline Offline
God Member
*****
Karma: 14
Posts: 717
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The binary numbers Bxxxxxxxx (8 digits) are defined in the headers for Arduino.

You can either expand yours to be 8 binary digits (B00010000) or just use the standard C convention 0b10000 (same way as 0x prefix would be used for hex numbers).
Logged


Offline Offline
Edison Member
*
Karma: 15
Posts: 1006
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can either expand yours to be 8 binary digits (B00010000) or just use the standard C convention 0b10000 (same way as 0x prefix would be used for hex numbers).

eight digit binary (like B00010000) are also defined in Arduino.h. I don't think 0b... is standard C, I think it's a gcc extension.

OP, just add
Code:
#include <Arduino.h>
at the top of the header file.
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 31
Posts: 1179
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a link to a post I made on Tom Torfs binary number macros.
It allows similar '0b' notation but is not compiler specific.

http://arduino.cc/forum/index.php/topic,93201.msg700368.html#msg700368
Logged


Pages: [1]   Go Up
Print
 
Jump to: