Code for buzzer and LCD
nic21
Posts: 12
I do not know what codes to write to activate the buzzer connect in series to p20.
Can someone advise me? Anyone know of C codes for LCD (16x2)?
int ping1; // Declare distance variable
int ping2; // Declare distance variable
int main() // main function
{
while(1) // Repeat indefinitely
{
ping1 = ping_cm(18); // Get cm distance from Ping)))
print("%c ping1 = %d%c cm", // Display distance
HOME, ping1, CLREOL);
pause(1000); // Wait 1/5 second
ping2 = ping_cm(19); // Get cm distance from Ping)))
print("%c ping2 = %d%c cm", // Display distance
HOME, ping2, CLREOL);
pause(1000); // Wait 1/5 second
if ((ping1<150)& (ping2<150))
{
//activate buzzer connected at propeller board (p20)
}
pause(1000);
}
Can someone advise me? Anyone know of C codes for LCD (16x2)?
int ping1; // Declare distance variable
int ping2; // Declare distance variable
int main() // main function
{
while(1) // Repeat indefinitely
{
ping1 = ping_cm(18); // Get cm distance from Ping)))
print("%c ping1 = %d%c cm", // Display distance
HOME, ping1, CLREOL);
pause(1000); // Wait 1/5 second
ping2 = ping_cm(19); // Get cm distance from Ping)))
print("%c ping2 = %d%c cm", // Display distance
HOME, ping2, CLREOL);
pause(1000); // Wait 1/5 second
if ((ping1<150)& (ping2<150))
{
//activate buzzer connected at propeller board (p20)
}
pause(1000);
}
Comments
This one?
You can find a Propeller C Simple Protocol tutorial using a serial LCD on our Learn site: http://learn.parallax.com/propeller-c-simple-protocols/half-duplex-serial.
What kind of buzzer are you trying to use? If it is a simple piezo speaker we have a tutorial for that as well: http://learn.parallax.com/propeller-c-simple-circuits/piezo-beep.
If it is a different kind of buzzer, you'll have to be more specific before we can point you in the right direction.