Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
25 views4 pages

Piezoelectric

The document contains an Arduino sketch that interfaces with a LiquidCrystal display to show voltage generated from footstep power generation. It reads analog values from a sensor, calculates the voltage, and displays it on the LCD while controlling an LED based on the voltage level. The code includes setup and loop functions, with a commented-out section for serial output and sample averaging.

Uploaded by

Avinash Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

Piezoelectric

The document contains an Arduino sketch that interfaces with a LiquidCrystal display to show voltage generated from footstep power generation. It reads analog values from a sensor, calculates the voltage, and displays it on the LCD while controlling an LED based on the voltage level. The code includes setup and loop functions, with a commented-out section for serial output and sample averaging.

Uploaded by

Avinash Garg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <LiquidCrystal.

h>

LiquidCrystal lcd(3, 5, 9, 10, 11, 12);

#define NUM_SAMPLES 10

int sum = 0; // sum of samples taken

unsigned char sample_count = 0; // current sample number

float voltage = 0.0; // calculated voltage

int green = 2 ;

void setup()

pinMode(green, OUTPUT);

digitalWrite(green, LOW);

lcd.begin(16, 2);

// Print a message to the LCD.

lcd.print("FOOT STEP");

lcd.setCursor(0, 1);

lcd.print("POWER GENERATION");

delay(1000);
delay(1000);

delay(1000);

delay(1000);

//Serial.begin(9600);

lcd.clear();

lcd.print("Volt Generated:-");

void loop()

// take a number of analog samples and add them up

/*

while (sample_count < NUM_SAMPLES)

sum += analogRead(A0);

sample_count++;

delay(10);

*/

// calculate the voltage

// use 5.0 for a 5.0V ADC reference voltage

// 5.015V is the calibrated reference voltage

sum = analogRead(A0);
if(sum>=180)

digitalWrite(green, HIGH);

voltage = ((float)sum * 5.015) / 1024.0;

// send voltage for display on Serial Monitor

// voltage multiplied by 11 when using voltage divider that

// divides by 11. 11.132 is the calibrated voltage divide

/* Serial.print(voltage * 11.132);

Serial.println (" Voltage");

*/

voltage = ((float)voltage * 11.132);

lcd.setCursor(0, 1);

lcd.print(voltage);

delay(400);

sample_count = 0;
sum = 0;

digitalWrite(green, LOW);

You might also like