element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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 Laser Harp issue please help
  • 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
  • Replies 14 replies
  • Subscribers 418 subscribers
  • Views 1675 views
  • Users 0 members are here
Related

Laser Harp issue please help

e14 Contributor
e14 Contributor over 13 years ago

Good Evening,

 

I was hoping you could help I am attempting to build a laser buzzer type harp with my Arduino I have followed a tutorial I found online however when it came to the programming I am experiencing an issue Error compiling

 

 

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::begin(uint8_t)':

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:121: error: 'bitWrite' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'digitalPinToPort' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:123: error: 'portOutputRegister' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:124: error: 'digitalPinToBitMask' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::play(uint16_t, uint32_t)':

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'OUTPUT' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:198: error: 'pinMode' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:294: error: 'bitWrite' was not declared in this scope

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp: In member function 'void Tone::stop()':

C:\Users\Scott\Documents\Arduino\libraries\Tone\Tone.cpp:361: error: 'digitalWrite' was not declared in this scope

 

here is the tutorial I have followed: http://www.radioshack.com/graphics/uc/rsk/Support/ProductManuals/Laser_Harp_Online_Instructions.pdf

 

Here is the code:

 

#include <Tone.h>

 

const boolean DEBUG = false;

 

const int CALIBRATION_PIN = A5;

const int SPEAKER_PIN = 8;

const int SENSOR_COUNT = 3;

 

typedef struct

{

  int pin;

  int note;

} sensor_type;

 

sensor_type sensor[SENSOR_COUNT];

 

Tone notePlayer;

 

void setup(void)

{

  if (DEBUG) {

    Serial.begin(9600);

  }

  sensor[0].pin = A0; // analog input 0, etc...

  sensor[0].note = NOTE_G3;

  sensor[1].pin = A1;

  sensor[1].note = NOTE_D4;

  sensor[2].pin = A2;

  sensor[2].note = NOTE_A4;

 

  notePlayer.begin(SPEAKER_PIN);

}

 

void loop(void)

{

  int calibration = analogRead(CALIBRATION_PIN);

  if (DEBUG) {

    Serial.print("cal: ");

    Serial.print(calibration);

  }

  int activeSensor = -1;

  for (int p = 0 ; p < SENSOR_COUNT ; p++) {

    int sensor_value = analogRead(sensor[p].pin);

    if (DEBUG) {

      Serial.print("\tsensor ");

      Serial.print(p);

      Serial.print(": ");

      Serial.print(sensor_value);

    }

    if ( sensor_value < calibration ) {

      activeSensor = p;

      if (DEBUG) Serial.print("!"); // "!" indicates note being played

    }

  }

  if (DEBUG) Serial.println();

  if (activeSensor == -1) {

    notePlayer.stop();

  } else {

    notePlayer.play(sensor[activeSensor].note);

  }

  if (DEBUG) delay(1000);

}

 

I look forward to your reply thanks in advance!

 

Scott

  • Sign in to reply
  • Cancel
Parents
  • billabott
    billabott over 13 years ago

    Trusting that a few of you out there may be experimenting with this sketch using Arduino 1.0, further research seemed to be in order.

     

    Doing so, just for fun, earned an inglorious reward: a bucket full of error messages from the IDE and a very unsuccessful compile.  The first "red line" warning told the whole story:  "C:\Users\microwattbott\Documents\Arduino\libraries\Tone\Tone.cpp:26:20: warning: wiring.h: No such file or directory"

     

    Due diligence brought me to: http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/

    Where something unexpected was learned about migrating libraries into the new and improved Arduino 1.0 IDE.

    If your sketch includes any libraries that have not been designed for 1.0

    then you will need to change the library if it uses any of the old header files

    that have been replaced with the new Arduino.h file. If you include any

    of these libraries, change:

         #include "wiring.h"

         #include "WProgram.h"

         #include "WConstants.h"

         #include "pins_arduino.h"

    To

         #include "Arduino.h"

     

    The fix was made by opening the library, Tone.cpp, for editing and the reference to wiring.h was replaced with the suggested Arduino.h.  Saving and recompiling the sketch was done with ease and success (queue marching bands and cheering crowds). 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 13 years ago in reply to billabott

    Billabot

    I note that most of the new/revised libraries detect the version of Arduino IDe and make the adjustment.

    Pity someone hasn't updated this one for the novices.

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • billabott
    billabott over 13 years ago in reply to mcb1

    I agree.  -billabott  aka Viewer44

    Mark Beckett wrote:

     

    Billabott

    I note that most of the new/revised libraries detect the version of Arduino IDe and make the adjustment.

    Pity someone hasn't updated this one for the novices.

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • billabott
    billabott over 13 years ago in reply to mcb1

    I agree.  -billabott  aka Viewer44

    Mark Beckett wrote:

     

    Billabott

    I note that most of the new/revised libraries detect the version of Arduino IDe and make the adjustment.

    Pity someone hasn't updated this one for the novices.

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube