Things used in this project

Hardware components:
Phpoc blue per 100x1000 euk22wtv9i
PHPoC Blue
×1
Relay (generic)
×1
12V LED Light
×1
SparkFun Sound Detector (SEN-12642)
×1

Schematics

Connecting to PHPoC Blue
[Sound detecting sensor] ---- [PHPoC Blue]
ENVELOPE ---- AD0
GATE ---- NSS/0
GND ---- GND
VCC ---- 3.3V

[Relay] ---- [PHPoC Blue]
IN ---- SCK/1
GND ---- GND
5V ---- PWR5
Sound detect bb jlpxasf2ao

Code

2. Clap once for On, Clap twice for OffPHP
It recognizes the number of noises within 500ms.
<?php
include_once "/lib/sd_340.php";
adc_setup(0, 0);
uio_setup(0, 0, "in");
uio_setup(0, 1, "out");
uio_out(0, 1, LOW); 
st_free_setup(0);
 
define("FINAL_DETECTED",    0);
define("CLAP_NOT_DETECTED",   1);
define("TIMEOUT",   2);
 
$start_time = 0;
 
function indicate_clap($clap_num)
{
    if($clap_num == 2) //2 clap
        uio_out(0, 1, LOW); 
 
    else if($clap_num == 1) //1 clap
        uio_out(0, 1, HIGH);    
    
    usleep(100000);
}
 
function detect_claps($clap_num)
{    
    global $start_time;
    
    if($clap_num == 2)  // 2 clap -> off
    {
        indicate_clap($clap_num);
 
        return FINAL_DETECTED;
    }
    
    $uio_in = uio_in(0, 0);    
    $adc_in = adc_in(0, 100);
    
    indicate_clap($clap_num); //no clap
        
    if($adc_in > 600 && $uio_in == 1) //clap detect
    {
        $start_time = st_free_get_count(0);
        $current_time = st_free_get_count(0);
    
        while(1)
        {
            if($current_time - $start_time < 500)
            {    
                $current_time = st_free_get_count(0);
                $clap_state = detect_claps($clap_num + 1);   
 
                if($clap_state == FINAL_DETECTED)
                    return $clap_state;
            }
            else 
                return TIMEOUT;            
        }    
    }
    
    return CLAP_NOT_DETECTED;
}
 
while(1)
{            
    $clap_state = detect_claps(0);
    
      if($clap_state == FINAL_DETECTED)
        indicate_clap(0);
 
    usleep(10000);          
}
?>
1. On/Off TogglePHP
<?php
include_once "/lib/sd_340.php";
adc_setup(0, 0);
uio_setup(0, 0, "in");
uio_setup(0, 1, "out");
uio_out(0, 1, LOW);
function control_led()
{
    uio_out(0, 1, TOGGLE);    
    usleep(100000);
}
while(1)
{        
    $uio_in = uio_in(0, 0);    //GATE 
    $adc_in = adc_in(0, 100); //ENVELOPE 
    
    if($adc_in > 600 && $uio_in == 1)
        control_led();
        
    usleep(10000);  
}
?>

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

PHPoC - Web-Based Thermometer
Easy
  • 128
  • 9

Full instructions

This project allows to check temperature at home from anywhere using web browser.

Arduino - Have Fun with Color Sensor
Easy
  • 517
  • 11

Full instructions

This project shows how to change color of Minion using Arduino, PHPoC WiFi Shield and color sensor.

PHPoC - Web-Based MP3 Player
Easy
  • 182
  • 8

Full instructions

This project shows how to control MP3 player via webpage using PHPoC.

Arduino - Web-Based Thermometer
Easy
  • 647
  • 11

Full instructions

This project allows you to check temperature at home from anywhere using web browser.

Electronic Voting Machine Using Arduino
Easy
  • 157
  • 5

It is an EVM using Arduino. There are five switches in all, assigned for various activities.

Assemble a PCB using Upverter and Fusion PCBA
Easy
  • 286
  • 5

Full instructions

Using an existing well written guide, our Hackster Live chapter designed, fabricated, and assembled an Arduino shield for a Simon Says game.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login