Portmanipulation - serial binary input

Hello!

I’m having some fun while learning about portmanipulation and i wrote a program which takes a decimal number from the serial monitor, which then lights up 8 LED’s in binary from.
Example, if i type in 1, 1 LED will light up and if i type 255 all 8 LED’s will light up.
I got this code to work, but now i want to make a progam where i type in a binary number in the serial monitor and i want it to work in the same way as my first program.
I’ve tried to do some research and i’m not any closer to finishing this code then i was when i started. It might be that i’ve been overthinking this and looking at the wrong places or that i just misinterpreted what i found. So any tips on this matter would be greatly appreciated!

Here is my code where i take a decimal input:

void setup() {
  Serial.begin(9600);
  DDRC = B11111111;
}

void loop() {
  Serial.println("Type in a number in decimal form: ");
  while (!Serial.available());
  byte number = Serial.parseInt();
  Serial.println(number);

  if (number < 256 and number >= 0) {
    PORTC = number;
  } else {
    PORTC = 0;
  }
}

Thanks in advance!

What is line ending in the the serial monitor?

uhh.. like i press enter? :o :o
I'm new to arduino and programming in general so i don't know many references yet..

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

…R

At the bottom of the serial monitor, to the right, are a bunch of controls.
What are they set to?

(you never actually explained what your problem is - I’m fishing)

TheMemberFormerlyKnownAsAWOL:
At the bottom of the serial monitor, to the right, are a bunch of controls.
What are they set to?

(you never actually explained what your problem is - I'm fishing)

ahh i see, mine is set to "no line ending".

Thingsnid:
ahh i see, mine is set to "no line ending".

And what happened when you tried the other settings?

The Arduino system is great for learning-by-doing

...R