0% found this document useful (0 votes)
47 views

Variable Frequency Arduino Program

This document summarizes an Arduino demo that uses a potentiometer to generate variable frequencies displayed on an LCD screen and LED. The circuit includes an LCD connected to Arduino pins to display output, a potentiometer connected to analog pin A0 to read input values, and an LED connected to pin 6 to demonstrate output. The Arduino code reads the potentiometer value, generates a tone at that frequency, displays the value on the LCD, and updates it each second. ###

Uploaded by

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

Variable Frequency Arduino Program

This document summarizes an Arduino demo that uses a potentiometer to generate variable frequencies displayed on an LCD screen and LED. The circuit includes an LCD connected to Arduino pins to display output, a potentiometer connected to analog pin A0 to read input values, and an LED connected to pin 6 to demonstrate output. The Arduino code reads the potentiometer value, generates a tone at that frequency, displays the value on the LCD, and updates it each second. ###

Uploaded by

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

###

/*============================ EG LABS ===================================//

Demonstration on how to use generate variable frequency using Arduino

The circuit:

LCD:

* LCD RS pin to digital pin 12

* LCD Enable pin to digital pin 11

* LCD D4 pin to digital pin 5

* LCD D5 pin to digital pin 4

* LCD D6 pin to digital pin 3

* LCD D7 pin to digital pin 2

* LCD R/W pin to ground

* 10K resistor:

* ends to +5V and ground

* wiper to LCD pin 3

* LED anode attached to digital output 6

* LED cathode attached to ground through a 1K resistor

Analog input:

* Potentiometer attached to analog input A0

* one side pin (either one) to ground

* the other side pin to +5V

* LED anode (long leg) attached to digital output 6

* LED cathode (short leg) attached to ground through a 1K resistor

//============================ EG LABS ===================================*/

// include the library code:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins

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

const int analogInPin = A0; // Analog input pin that the potentiometer is attached
to

const int analogOutPin = 6; // Analog output pin that the LED is attached to

int potvalue = 0;

int outputvalue=0;

void setup()

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

lcd.print("ENGINEERS GARAGE");

void loop()

potvalue = analogRead(analogInPin); // raed the


analog value

tone(8, potvalue); // generate


the frequency at the same value

lcd.clear(); // display the


value in the LCD

lcd.print(potvalue);

lcd.print(" Hz");

delay(1000);

noTone(8); // stop the waveform


and start with the new analog input value

###

You might also like