Pages: [1]   Go Down
Author Topic: Trying to use binary number (B10000) in lib and getting error.  (Read 505 times)
0 Members and 1 Guest are viewing this topic.
Manchester, New Hampshire
Offline Offline
Edison Member
*
Karma: 1
Posts: 1291
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, Australia
Offline Offline
Edison Member
*
Karma: 27
Posts: 1187
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

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Offline Offline
Edison Member
*
Karma: 17
Posts: 1041
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: 53
Posts: 1801
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
Jump to: