###
/*============================ 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
###