Upload Successful but No Print Output

I am using a new Arduino Mega to measure some sensors. I've set up the code to print the data that is measured.

Upon uploading, I get no error. However, the script does not print out the measurement values. So, I assume that the script isn't running in the first place.

The Tools>Port shows the Arduino Mega on COM4 and when I unplug the Mega, COM4 disappears, so the connection seems okay.

I've also selected the Arduino Mega as the Tools>Board.

Any help for an Arduino newbie?

Code below:

#include <stdio.h>

float pressure0;
float pressure1;
float pressure2;
float pressure3;
float pressure4;
float pressure5;

int pressurePin0 = 0;
int pressurePin1 = 1;
int pressurePin2 = 2;
int pressurePin3 = 3;
int pressurePin4 = 4;
int pressurePin5 = 5;

void setup() {
   Serial.begin(9600);
   pinMode(13, OUTPUT);
}

void loop() {
   pressure0 = analogRead(pressurePin0);
   pressure1 = analogRead(pressurePin1);
   pressure2 = analogRead(pressurePin2);
   pressure3 = analogRead(pressurePin3);
   pressure4 = analogRead(pressurePin4);
   pressure5 = analogRead(pressurePin5);
   
   // read analog volt from sensor and save to variable temp
   // convert the analog volt to its temperature equivalent

   Serial.print(pressure0);
   Serial.print('t');
   Serial.print(pressure1);
   Serial.print('t');
   Serial.print(pressure2);
   Serial.print('t');
   Serial.print(pressure3);
   Serial.print('t');
   Serial.print(pressure4);
   Serial.print('t');
   Serial.print(pressure5);
   Serial.print('t');
      
   Serial.println();
   delay(100); // update sensor reading each one tenth of a second
}

Did you open the serial monitor?

So, I assume that the script isn't running in the first place.

No if code downloads it is running. You can never get an Arduino to not run code, unless you put it in sleep mode. Something will be running even if it is stuck in an endless loop and you see no result.

Just because something compiles and loads does not mean it will do what you want it to do. The compiler can only read your code, not your mind.

I am with AWOL with his one though. Is the serial monitor set the the same baud rate as your code?

Grumpy_Mike:
You can never get an Arduino to not run code, unless you put it in sleep mode.

...or connect the Reset pin to Ground. But then you can't upload.

Python (Raspberry Pi) runs scripts. Arduino IDE compiles sketches.

Hi,
Try this edit of your code;

#include <stdio.h>


float pressure0;
float pressure1;
float pressure2;
float pressure3;
float pressure4;
float pressure5;


int pressurePin0 = A0;
int pressurePin1 = A1;
int pressurePin2 = A2;
int pressurePin3 = A3;
int pressurePin4 = A4;
int pressurePin5 = A5;


void setup() {
   Serial.begin(9600);
   Serial.println("Beginning program");
   pinMode(13, OUTPUT);
}


void loop() {
   pressure0 = analogRead(pressurePin0);
   pressure1 = analogRead(pressurePin1);
   pressure2 = analogRead(pressurePin2);
   pressure3 = analogRead(pressurePin3);
   pressure4 = analogRead(pressurePin4);
   pressure5 = analogRead(pressurePin5);
  
   // read analog volt from sensor and save to variable temp
   // convert the analog volt to its temperature equivalent


   Serial.print(pressure0);
   Serial.print("t");
   Serial.print(pressure1);
   Serial.print("t");
   Serial.print(pressure2);
   Serial.print("t");
   Serial.print(pressure3);
   Serial.print("t");
   Serial.print(pressure4);
   Serial.print("t");
   Serial.print(pressure5);
   Serial.print("t");
      
   Serial.println();
   delay(100); // update sensor reading each one tenth of a second
}

Analog pins are A0 A1 etc.

Look at Serial print " and not '

Make sure you have 9600 baud selected in the monitor window.

Tom..... :slight_smile: