Koe Josephine Lab 4 Code


#include <LiquidCrystal.h>

 

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 

// these constants describe the pins. They won't change:

const int xpin = A3;                  // x-axis of the accelerometer

const int ypin = A2;                  // y-axis

const int zpin = A1;                  // z-axis (only on 3-axis models)

 

void setup()

{

  lcd.begin(16, 2); 

}

 

void loop()

{

  // print the sensor values:

  lcd.print("X");

  lcd.print(analogRead(xpin));

  // print a tab between values:

  lcd.print("  Y");

  lcd.print(analogRead(ypin));

  // print a tab between values:

  lcd.print("  Z");

  lcd.print(analogRead(zpin));

  // delay before next reading:

  delay(500);

  lcd.clear();

}