Hi all. I'm a beginner with Arduino, and I'm using it for a Digital and Electronic Art class. I have a functioning code; however, I'm wondering how to make the serial monitor sequentially display a new case (these are poem stanzas) with each press of the button.
Right now, the serial monitor displays the entire poem in one button press.
Thanks in advance!
const int buttonPin = 2;
int buttonPushCounter = 0;
boolean buttonState = LOW;
boolean lastButtonState = LOW;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
{
buttonPushCounter = 0;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter)
{
case 0:
Serial.println("It seems foreign, now.");
Serial.println("All of this,");
Serial.println("Being here.");
break;
}
}
}
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
{
buttonPushCounter = 1;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter)
{
case 1:
Serial.println("The chambers,");
Serial.println("The calcified surface of a heart,");
Serial.println("A tarred, rotten thing.");
break;
}
}
}
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
{
buttonPushCounter = 2;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter)
{
case 2:
Serial.println("Still, a pool of warm blood within,");
Serial.println("Feverish, thrasing, desperate.");
break;
}
}
}
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
{
buttonPushCounter = 3;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter)
{
case 3:
Serial.println("Let it circulate endlessly through familiar chambers and valves.");
Serial.println("Moving, yes.");
Serial.println("But only from within.");
break;
}
}
}
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
buttonPushCounter++;
{
buttonPushCounter = 4;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter)
{
case 4:
Serial.println("Chambers and valves.");
Serial.println("All I am is chambers and valves,");
Serial.println("A breathing, wretched thing.");
break;
}
}
}
lastButtonState = buttonState;
}