0
votes

In setup() the I have Serial.begin(9600), but there is no text being displayed whenever I have the Serial Monitor print anything. I have tried moving the location of the print() functions (including directly under Serial.begin()), but nothing has worked.

#include <Stepper.h>
#include "CommandTest.h"
#include "BlueSide.h"
#include "RedSide.h"
#include "GreenSide.h"
#include "YellowSide.h"
#include "OrangeSide.h"
#include "WhiteSide.h"

void setup(){
  Serial.begin(9600);
  delay(1);
  Serial.print("test"); //not displaying even this
  char temp[] = "wwwwwwwww";
  WhiteSide::setValue(temp);
  strcpy(temp, "rrrrrrrrr");
  RedSide::setValue(temp);
  strcpy(temp, "bbbbbbbbb");
  BlueSide::setValue(temp);
  strcpy(temp, "ooooooooo");
  OrangeSide::setValue(temp);
  strcpy(temp, "ggggggggg");
  GreenSide::setValue(temp);
  strcpy(temp, "yyyyyyyyy");
  YellowSide::setValue(temp);
  delay(1000);
}

void printCube(){
  Serial.println(WhiteSide::getArray());
  Serial.println(RedSide::getArray());
  Serial.println(BlueSide::getArray());
  Serial.println(OrangeSide::getArray());
  Serial.println(GreenSide::getArray());
  Serial.println(YellowSide::getArray());
}

int main(){
  CommandTest command;
  Serial.print("start");//not displaying this
  command.f();
  printCube();//and it's not printing these arrays
  delay(1000);
  command.fp();
  printCube();
  delay(1000);
  command.r();
  printCube();
  delay(1000);
  command.rp();
  printCube();
  delay(1000);
  command.l();
  printCube();
  delay(1000);
  command.lp();
  printCube();
  delay(1000);
  return 0;
}
2

2 Answers

2
votes

In your Arduino sketch you do not need to write a main function. The only required functions are setup and loop.

Your locally declared main is being used instead of the one supplied by the Arduino core (this is allowed because the arduino main comes from a library, so your main supercedes it). Therefore setup is never called.

Rename your int main() to void loop() and remove the return 0; from the end.

0
votes

This may seem obvious, but did you consider adding the setup() function to main? Without actually enabling the serial module you're not likely to see anything. It has been a while since I've used an Arduino, but from what I recall, setting up the serial output was fairly simple.

You may also want to check that your wiring is correct. An oscilloscope will work quite well in this case, however a simple review may also suffice.