How can I use tone() instruction on UDOO

Discussion in 'Arduino IDE' started by hushunghung, Dec 25, 2013.

  1. hushunghung

    hushunghung New Member

    Joined:
    Dec 2, 2013
    Messages:
    6
    Likes Received:
    0
    Dear All

    After receiving UDOO, I found it is Arduino Due Model.
    But I practicing the sounder experience, I need tone() instruction.
    But it seems can't work for this model.
    So How can I replace this instruction or have something new ideas?

    Code:
    float sinVal;
    int toneVal;
    void setup() {
      // put your setup code here, to run once:
      pinMode(8,OUTPUT);
    }
    
    void loop() {
      // put your main code here, to run repeatedly: 
      for(int x=0;x<180;x++){
        sinVal = (sin(x*(3.1412/180)));
        toneVal = 2000+(int(sinVal*1000));
        tone(8,toneVal);
        delay(2);
      }
    }
     
  2. miousername

    miousername New Member

    Joined:
    Jun 23, 2013
    Messages:
    73
    Likes Received:
    0
    Hi,

    Which is the problem?The application doesn't compile or when you launch the application you can't hear sound?
     
  3. hushunghung

    hushunghung New Member

    Joined:
    Dec 2, 2013
    Messages:
    6
    Likes Received:
    0
    My problem is

    1. use tone can't compile, how to solve arduino due rev can't use tone and notone,even though I've import its library. (# include <Tone.h>)
    2. I've check /opt/arduino-1.5.4/hardware/cores/arduino/ Tone.h and Arduino.h and I check its content with entry for "Tone.h". In network, I found the method, but its not work.(tone.h rename to arduino.h)
    3. How can I find a new instruction method for replacing tone and notone?
     
  4. francescomm

    francescomm Member

    Joined:
    Dec 14, 2013
    Messages:
    80
    Likes Received:
    4
    3: if I remember well, this example plays tones without using tone();

    http://www.arduino.cc/en/Tutorial/PlayMelody

    It is just a matter of turning a pin current hi, waiting the correct time, then low, waiting the correct time, then hi, etc..
    You are manually generating the wave. Correct wait times for some notes are listed in the script (if I remember well).
    You can adjust volume (0-255) too by using analog output instead of digital hi vs low (if I remember well).

    [P.S:. of course on UDOO you can play (much better) audio on the Linux side easily, but you probably know]
     
  5. sgygax

    sgygax New Member

    Joined:
    Jul 22, 2016
    Messages:
    21
    Likes Received:
    0
    Dear all
    tone() is not supported. If I compile a Sketch with tone() I get error message:
    - error: 'tone' was not declared in the scope
    There is nothing written about it in chapter "Arduino differences".
    Is there a solution?
    Best regards!
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    What Udoo are you on? This discussion started for a Udoo Dual/Quad.
    I think you have a Udoo Neo right? Then you have to use something like TimerFreeTone
    For more info alo look here https://bitbucket.org/teckel12/arduino-timer-free-tone/wiki/Home
     

Share This Page