element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Need 10 minutes from an Arduino Expert
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 34 replies
  • Subscribers 395 subscribers
  • Views 2224 views
  • Users 0 members are here
  • arduino
Related

Need 10 minutes from an Arduino Expert

gub11
gub11 over 10 years ago

Having some noob trouble with a sketch, and an arduino uno, i'm sure anybody with more knowledge than me could help.

add me on skype, gabe.spound2

  • Sign in to reply
  • Cancel

Top Replies

  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago in reply to gub11 +2
    The people trying to help here are all over the world.. literally so many different time zones, we get to respond when we have a moment from our busy lives and as a principal we dont skype etc, this would…
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago +1
    Can you please simply post your issue here with sketch, diagrams and description of the problem then many folks will be able to help and then the answer will also help many
  • mcb1
    mcb1 over 10 years ago in reply to gub11 +1
    gub11 Okay so you've included the code for the LED. What about including what you did for the relay. Note to include code paste the code, then select it. Click on the >> and then select Syntax highlighting…
Parents
  • Robert Peter Oakes
    0 Robert Peter Oakes over 10 years ago

    Can you please simply post your issue here with sketch, diagrams and description of the problem then many folks will be able to help

     

    and then the answer will also help many

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gub11
    0 gub11 over 10 years ago in reply to Robert Peter Oakes

    ok, im just not a hundred percent sure what the problem is any when i do that people just shoot what they think will work and don't help me out, i really just need somebody to skype w/ me so i can show them the issue, but ill try to sum it up.

    Sketch Below.

    Basically, i have analog read on A0 and if it's greater than 8 digital write pin 2 high, less than 2, write low.  on an led it works great, led on when clap is heard, led off once more when clap is heard again.  but when i hook it up toa relay, the relay just goes on then off, it doesn't stay off

     

    int analogValue;          // This is where we'll store our audio to digital value.  More sound = higher number
    #define LED 2             // Set up the LED indicator
    boolean toggle = false;   // setup a boolean function called toggle which will help us to choose which mode we're in
    int numberOfClaps = 0;
    void setup()
    {
      pinMode
    (LED,OUTPUT);    // Pin#2 should be conencted to an LED through a 300-600 ohm resistor   
     
    Serial.begin(9600);     // This is optional - It just helps you to calibrate sensitivity after the fact
    }

    void loop()
    {
     
    if (toggle == false)   // When you power up your arduino, boolean "toggle" is set to false, so the following section of code will                          //commence.  The "ELSE" is ignored for now.
       
    {
          digitalWrite
    (LED,LOW);        // Turn the LED off
          analogValue
    = analogRead(0);  // Take an analog reading from A0 line.  No sounds should be offer a returned value of "0"
         
    if (analogValue > 8)          // If higher than 8 is returned, then change state of boolean "toggle" to true, display analogValue to                                     // serial monitor and wait 200ms.
         
    // The higher the value in the above "if" statement, the less sensitive your clapper will be.  Use the serial monitor to calibrate to       // your wanted sensitivity =D
         
    {
            toggle
    = true;
           
    Serial.println(analogValue);
            delay
    (200);
         
    }
       
    }
       
    else                            // If boolean "toggle" has beenchanged to true, then the above section of code will be ignored, and the                                     // code below will commence.
       
    {
          digitalWrite
    (LED,HIGH);       // Turn the LED on
          analogValue
    = analogRead(0);  // Take an analog reading from A0 line.  No sounds should be offer a returned value of "0"
         
    if (analogValue > 8)          // If higher than 8 is returned, then change state of boolean "toggle" back to false, print analogValue                                     // to serial monitor and wait 200ms.
         
    // The higher the value in the above "if" statement, the less sensitive your clapper will be.  Use the serial monitor to calibrate to       // your wanted sensitivity =D
         
    {
            toggle
    = false;
           
    Serial.println(analogValue);
            delay
    (200);
         
    }
       
    }
    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 10 years ago in reply to gub11

    gub11

    Okay so you've included the code for the LED.

     

    What about including what you did for the relay.

     

    Note to include code paste the code, then select it.

    Click on the  >> and then select Syntax highlighting, and C++.

    You find it then looks like below...

     

    int analogValue;          // This is where we'll store our audio to digital value.  More sound = higher number
    #define LED 2             // Set up the LED indicator
    boolean toggle = false;   // setup a boolean function called toggle which will help us to choose which mode we're in
    int numberOfClaps = 0;
    void setup()
    {
      pinMode(LED,OUTPUT);    // Pin#2 should be conencted to an LED through a 300-600 ohm resistor    
      Serial.begin(9600);     // This is optional - It just helps you to calibrate sensitivity after the fact
    }
     
    void loop()
    {
      if (toggle == false)   // When you power up your arduino, boolean "toggle" is set to false, so the following section of code will                          //commence.  The "ELSE" is ignored for now.
        { 
          digitalWrite(LED,LOW);        // Turn the LED off
          analogValue = analogRead(0);  // Take an analog reading from A0 line.  No sounds should be offer a returned value of "0"
          if (analogValue > 8)          // If higher than 8 is returned, then change state of boolean "toggle" to true, display analogValue to                                     // serial monitor and wait 200ms.
          // The higher the value in the above "if" statement, the less sensitive your clapper will be.  Use the serial monitor to calibrate to       // your wanted sensitivity =D
          {
            toggle = true;
            Serial.println(analogValue);
            delay(200);
          }
        }
        else                            // If boolean "toggle" has beenchanged to true, then the above section of code will be ignored, and the                                     // code below will commence.
        {
          digitalWrite(LED,HIGH);       // Turn the LED on
          analogValue = analogRead(0);  // Take an analog reading from A0 line.  No sounds should be offer a returned value of "0"
          if (analogValue > 8)          // If higher than 8 is returned, then change state of boolean "toggle" back to false, print analogValue                                     // to serial monitor and wait 200ms.
          // The higher the value in the above "if" statement, the less sensitive your clapper will be.  Use the serial monitor to calibrate to       // your wanted sensitivity =D
          {
            toggle = false;
            Serial.println(analogValue);
            delay(200);
          }
        }
    }

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gub11
    0 gub11 over 10 years ago in reply to mcb1

    thats what im using for the relay lol, what should i do to toggle a relay when analog input on a0 is greater than 9, i thought itd be the same

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • balearicdynamics
    0 balearicdynamics over 10 years ago in reply to gub11

    I have the suspect that maybe the circuit. Can you post the scheamtic of your relay circuit ?

     

    Thank you. Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gub11
    0 gub11 over 10 years ago in reply to balearicdynamics

    sureyou may have to follow the wires with ur finger, but its all thereimage

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • gub11
    0 gub11 over 10 years ago in reply to balearicdynamics

    sureyou may have to follow the wires with ur finger, but its all thereimage

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • mcb1
    0 mcb1 over 10 years ago in reply to gub11

    @gub11

    Sorry but your photo is not that clear on where all the wires go to.

     

    Your code uses Pin2 for the LED (which you say works fine), but the photo looks like you are using pin 6.

    In the same manner your power looks like 5v and 3v3 rather than ground.

     

    This may be an illusion but without clear schematic or picture no amount of skype will help.

     

    Also this post serves as a reference to others,  who may have similar issues.

     

    Mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • gub11
    0 gub11 over 10 years ago in reply to mcb1

    well the problem isn't the circuit, i know that, that's the part im good at, the only thing i don't really know how to work is the relay

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 10 years ago in reply to gub11

    well the problem isn't the circuit, i know that, that's the part im good at, the only thing i don't really know how to work is the relay

    im sure its a simple issue, i just don't know much

    Please take this constructively ...

    The two statements above suggest that there are parts of the circuit you don't understand.

     

    If you don't want to provide the information when someone asks, then I hope you have good luck in resolving your problem.

     

    Thanks

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube