Project showcase
Web Piano (Control Buzzer by Web)

Web Piano (Control Buzzer by Web) © GPL3+

Web-based buzzer controlled with PHPoC Shield for Arduino.

  • 1,709 views
  • 0 comments
  • 14 respects

Components and supplies

About this project

Project

The Web Piano is a web-based buzzer controlled with PHPoC Shield for Arduino.

Items

  • Arduino Uno
  • PHPoC Shield for Arduino (P4S-348)
  • Buzzer (Catalex Buzzer v1.0)

How it works

  • Connect PHPoC Shield for Arduino on your Arduino
  • Connect USB wireless LAN dongle to the shield for using WLAN
  • Access to the shield's web page and control your buzzer in web application

Demo Video

Code

Web_Piano.inoC/C++
/* arduino web server - remote control (push button) */

#include "SPI.h"
#include "Phpoc.h"

#define NOTE_C5  523
#define NOTE_D5  587
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_G5  784
#define NOTE_A5  880
#define NOTE_B5  988

PhpocServer server(80);

int Buzzer = 9;

void setup() {
  pinMode(9, OUTPUT);
  Serial.begin(9600);
  while(!Serial)
    ;

  Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
  //Phpoc.begin();

  server.beginWebSocket("remote_push");

  Serial.print("WebSocket server address : ");
  Serial.println(Phpoc.localIP());  
}

void loop() {
  // wait for a new client:
  PhpocClient client = server.available();

  if (client) {
    if (client.available() > 0) {
      // read the bytes incoming from the client:
      char thisChar = client.read();
      
      Serial.println(thisChar);

      if(thisChar == 'A')
      {
         Serial.println("button A press");
         tone(Buzzer, NOTE_C5);
      } 
      if(thisChar == 'a') {
         Serial.println("button A release");
         noTone(Buzzer);
      }
      if(thisChar == 'B')
      {
         Serial.println("button B press");
         tone(Buzzer, NOTE_D5);
      }  
      if(thisChar == 'b') {
         Serial.println("button B release");
         noTone(Buzzer);         
      }   
      if(thisChar == 'C') {
         Serial.println("button C press");
         tone(Buzzer, NOTE_E5);
      }
      if(thisChar == 'c') {
         Serial.println("button C release");
         noTone(Buzzer);         
      }   
      if(thisChar == 'D') {
         Serial.println("button D press");        
         tone(Buzzer, NOTE_F5);
      }
      if(thisChar == 'd') {
         Serial.println("button D release");        
         noTone(Buzzer);
      }      
      if(thisChar == 'E') {
         Serial.println("button E press");
         tone(Buzzer, NOTE_G5);         
      }
      if(thisChar == 'e') {
         Serial.println("button E release");        
         noTone(Buzzer);
      }      
      if(thisChar == 'F') {
         Serial.println("button F press");
         tone(Buzzer, NOTE_A5);         
      }
      if(thisChar == 'f') {
         Serial.println("button f release");        
         noTone(Buzzer);
      }            
      if(thisChar == 'G') {
         Serial.println("button G press");
         tone(Buzzer, NOTE_B5);         
      }
      if(thisChar == 'g') {
         Serial.println("button g release");        
         noTone(Buzzer);
      }            
      if(thisChar == 'H') {
         Serial.println("button H press");
         tone(Buzzer, NOTE_C6);         
      }
      if(thisChar == 'h') {
         Serial.println("button H release");        
         noTone(Buzzer);
      }
     }
  }
}

Comments

Similar projects you might like

Arduino - Control Arm Robot via Web

Project tutorial by phpoc_man

  • 17,028 views
  • 23 comments
  • 159 respects

Arduino - Control Step Motor Precisely via Web

Project tutorial by IoT_lover

  • 12,687 views
  • 3 comments
  • 76 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 11,128 views
  • 5 comments
  • 32 respects

Arduino Dynamic Web Control

Project tutorial by phpoc_man

  • 44,017 views
  • 19 comments
  • 152 respects

Arduino - Control Light Bulb via Web

Project tutorial by Homer

  • 11,593 views
  • 15 comments
  • 64 respects

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 9,831 views
  • 3 comments
  • 16 respects
Add projectSign up / Login