0

I am attempting to do a simple example with the Rotary Angle Sensor.

Here is my development environment:

Visual Studio Solution and Projects

Board setup (Simple as can be single analog input): Seeeduino V3 Setup

Code:

const int ROTARYSENSOR = A0; 

void setup()
{
    Serial.println("Setup Start...");
    Serial.begin(9600); //Set the serial communication frequency at 9600 bits per second

    pinMode(ROTARYSENSOR, INPUT);

    Serial.println("Setup End!");
}

void loop()
{
    Serial.println("Loop Start...");

    int value = analogRead(ROTARYSENSOR);
    Serial.println(value); //display on serial monitor
    delay(1000); //wait 1000ms before printing next value

    Serial.println("Loop End!");
}

Issue:

I have a single solution with multiple projects as my sensor playground. All other projects I have so far work flawlessly no issues. Although with this project (RotaryAngleSensor) I am getting a strange message.

I am not seeing any of the Serial.println() messages. What is printed to the screen after a good 30 seconds is S?

Does anyone know what could be returning this S? to the standard output?

3
  • Did you not post all your code? The setup() function is only called once, at the very start of the program running. It's possible you're just missing them. Aug 15, 2014 at 0:58
  • Also, to be precise, your "rotary angle sensor" is actually called a potentiometer. Aug 15, 2014 at 0:58
  • Yeah I lost some code somehow, when I was editing. I will update it. Also yeah I know what it's called, I was just using the name that was on the container box. :p Aug 15, 2014 at 3:07

1 Answer 1

2

One problem is that you try to generate serial output before you initiate Serial. This could have odd results beyond just making that message fail.

Serial.println("Setup Start...");
Serial.begin(9600);

Should be

Serial.begin(9600);
Serial.println("Setup Start...");

And of course your posted code never reads the sensor...

2
  • It does, I must have lost the loop method when I reedited my question. Thanks. Aug 15, 2014 at 3:06
  • So I flipped it around like suggested still didn't work. But when I remove the Serial.begin(9600); all together it works just fine, but just starts at 0. Suggestions? Aug 15, 2014 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.