Hello,
As I couldn't find a correct answer in the web, and I'm very new in Arduino programing, I dare to ask here.
In the Code below I try to initialize some byte Variables in Binary Format in the afficher(int x) function. But it gives me Errors back.
The Code is from the Web and I changed it a bit. I already tried to use the IDE function Tools/Autoformat and Tools/Fix-Encoding & Reload, without Success and Problems.
It's just for learning and testing.
How could it be solved ?
byte ledPin[8] = {2, 3, 4, 5, 6, 7, 8, 9}; // Numbers of pins on the Arduino
byte code[10] = {63, 6, 91, 79, 102, 109, 124, 7, 127, 103}; // code numbers 0 to 9: 63,6,91,79,102,109,124,7,127,103
int unite = 0; // <U+202D>00111111<U+202C>, <U+202D>0110<U+202C>, <U+202D>01011011<U+202C>, <U+202D>01001111<U+202C>, <U+202D>01100110<U+202C>, <U+202D>01101101<U+202C>, <U+202D>01111100<U+202C>, <U+202D>0111<U+202C>, <U+202D>01111111<U+202C>, <U+202D>01100111<U+202C>
int dizaine = 0;
int duree;
void setup()
{
randomSeed(analogRead(0));
Serial.begin(9600);
for (int i = 0; i <= 8; i++) // configuration of pins 2 to 9 in output
{
pinMode(ledPin[i], OUTPUT);
}
Serial.println("---------- Number guess Game -----------");
Serial.println("Type a Number to play : ");
}
// Program principal
void loop()
{
int i = random(0, 100);
//duree=millis() / 1000; // stopwatch
dizaine = i / 10; // Extraction of tens
unite = i % 10; // Extraction of units
if (duree >= 100) // RAZ when counter reach 99
{
dizaine = 0;
unite = 0;
}
digitalWrite(9, LOW); // selection of units on display
afficher(code[unite]); // show units
delay(2000);
digitalWrite(9, HIGH); // selection of tens on display
afficher(code[dizaine]); //show tens
delay(2000);
}
void afficher(int x) // Procedure coding the number in 7 segments
{
byte zero = B00111111;
byte one = B0000<U+202D>0110;
byte two = B01011011;
byte three = B<U+202D>01001111;
byte for4 = B01100110;
byte five = B<U+202D>01101101<U+202C>;
byte six = B01111100;
byte seven = B00000111<U+202C>;
byte eight = B01111111<U+202C>;
byte nine = B<U+202D>01100111;
byte chiffre = x;
byte segment = 0;
for (int i = 2; i < 9; i++)
{
segment = chiffre & 00000001;
//digitalWrite(i,segment);
//chiffre=chiffre>>1;
Serial.flush();
//while(Serial.available() == 0) {}
Serial.println(one, DEC);
if ((Serial.read() - '0') == 0) {
if ((byte)segment == zero) {
Serial.print("Win, your Number is correct !");
Serial.print("0");
}
}
if ((Serial.read() - '0') == 1) {
if ((byte)segment == one) {
Serial.print("Win, your Number is correct !");
Serial.print("1");
}
}
if ((Serial.read() - '0') == 2) {
if ((byte)segment == two) {
Serial.print("Win, your Number is correct !");
Serial.print("2");
}
}
if ((Serial.read() - '0') == 3) {
if ((byte)segment == three) {
Serial.print("Win, your Number is correct !");
Serial.print("3");
}
}
if ((Serial.read() - '0') == 4) {
if ((byte)segment == for4) {
Serial.print("Win, your Number is correct !");
Serial.print("4");
}
}
if ((Serial.read() - '0') == 5) {
if ((byte)segment == five) {
Serial.print("Win, your Number is correct !");
Serial.print("5");
}
}
if ((Serial.read() - '0') == 6) {
if ((byte)segment == six) {
Serial.print("Win, your Number is correct !");
Serial.print("6");
}
}
if ((Serial.read() - '0') == 7) {
if ((byte)segment == seven) {
Serial.print("Win, your Number is correct !");
Serial.print("7");
}
}
if ((Serial.read() - '0') == 8) {
if ((byte)segment == eight) {
Serial.print("Win, your Number is correct !");
Serial.print("8");
}
}
if ((Serial.read() - '0') == 9) {
if ((byte)segment == nine) {
Serial.print("Win, your Number is correct !");
Serial.print("9");
}
}
digitalWrite(i, segment);
chiffre = chiffre >> 1;
}
}
Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
sketch_oct04a:59:20: error: stray '\342' in program
* byte one = 0b00000110;*
* ^*
sketch_oct04a:59:21: error: stray '\200' in program
* byte one = 0b00000110;*
* ^*
sketch_oct04a:59:22: error: stray '\255' in program
* byte one = 0b00000110;*
* ^*
sketch_oct04a:61:18: error: stray '\342' in program
* byte three = 0b01001111;*
* ^*
sketch_oct04a:61:19: error: stray '\200' in program
* byte three = 0b01001111;*
* ^*
sketch_oct04a:61:20: error: stray '\255' in program
* byte three = 0b01001111;*
* ^*
sketch_oct04a:62:17: error: stray '\342' in program
* byte for4 = 0b01100110;*
* ^*
sketch_oct04a:62:18: error: stray '\200' in program
* byte for4 = 0b01100110;*
* ^*
sketch_oct04a:62:19: error: stray '\255' in program
* byte for4 = 0b01100110;*
* ^*
sketch_oct04a:63:17: error: stray '\342' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:63:18: error: stray '\200' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:63:19: error: stray '\255' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:63:28: error: stray '\342' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:63:29: error: stray '\200' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:63:30: error: stray '\254' in program
* byte five = 0b01101101;*
* ^*
sketch_oct04a:64:16: error: stray '\342' in program
* byte six = 0b01111100;*
* ^*
sketch_oct04a:64:17: error: stray '\200' in program
* byte six = 0b01111100;*
* ^*
sketch_oct04a:64:18: error: stray '\255' in program
* byte six = 0b01111100;*
* ^*
sketch_oct04a:65:26: error: stray '\342' in program
* byte seven = 0b00000111;*
* ^*
sketch_oct04a:65:27: error: stray '\200' in program
* byte seven = 0b00000111;*
* ^*
sketch_oct04a:65:28: error: stray '\254' in program
* byte seven = 0b00000111;*
* ^*
sketch_oct04a:66:26: error: stray '\342' in program
* byte eight = 0b01111111;*
* ^*
sketch_oct04a:66:27: error: stray '\200' in program
* byte eight = 0b01111111;*
* ^*
sketch_oct04a:66:28: error: stray '\254' in program
* byte eight = 0b01111111;*
* ^*
sketch_oct04a:67:17: error: stray '\342' in program
* byte nine = 0b01100111;*
* ^*
sketch_oct04a:67:18: error: stray '\200' in program
* byte nine = 0b01100111;*
* ^*
sketch_oct04a:67:19: error: stray '\255' in program
* byte nine = 0b01100111;*
* ^*
\Documents\Arduino\sketch_oct04a\sketch_oct04a.ino: In function 'void afficher(int)':
sketch_oct04a:59:23: error: expected ',' or ';' before numeric constant
* byte one = 0b00000110;*
* ^~~~*
sketch_oct04a:61:16: error: unable to find numeric literal operator 'operator""b'
* byte three = 0b01001111;*
* ^~*
sketch_oct04a:62:15: error: unable to find numeric literal operator 'operator""b'
* byte for4 = 0b01100110;*
* ^~*
sketch_oct04a:63:15: error: unable to find numeric literal operator 'operator""b'
* byte five = 0b01101101;*
* ^~*
sketch_oct04a:64:14: error: unable to find numeric literal operator 'operator""b'
* byte six = 0b01111100;*
* ^~*
sketch_oct04a:67:15: error: unable to find numeric literal operator 'operator""b'
* byte nine = 0b01100111;*
* ^~*
exit status 1
stray '\342' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.