Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7434223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:48:04+00:00 2026-05-29T09:48:04+00:00

I was trying to build a basic theremin with my Arduino for didactic purpose.

  • 0

I was trying to build a basic theremin with my Arduino for didactic purpose.
My idea was reading a potentiometer for the volume and a photoresistor for the pitch.

My code right now is:

 int piezoPin = 5;
 int sensorPin = 1;
 int potPin = 2;

 int sogliaMinima = 20;
 int sogliaMassima = 160;

 void setup () {
   pinMode (piezoPin, OUTPUT);
   Serial.begin (9600);
 }

 void loop () {
  // first block of code working
  int potLevel = analogRead (potPin);
  int levelVolume = map (potLevel, 0, 1022, 0, 170);
  analogWrite (piezoPin, levelVolume);


  // second block of code working
  int sensorValue = analogRead (sensorPin);
  int pitchLevel = map (sensorValue, sogliaMinima, sogliaMassima, 100, 1000);
  tone (piezoPin, pitchLevel);
 }

This is not working, and it’s a software issue not a circuit mistake. Both first block and second block are working if commenting one of them, but don’t work together. So my question is: can I use tone() and analogWrite on the same pin?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:48:04+00:00Added an answer on May 29, 2026 at 9:48 am

    You are correct. You can’t use both functions on the same pin. The two functions analogWrite and tone both attempt to control the pin with a PWM signal. Doing both in sequence changes their defaults. For analogWrite, the tone is 490Hz.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to build a very basic serial shell with my arduino.
I'm trying to build a simple .Net wrapper around some basic C++ code. The
I'm a JavaScript novice trying to build a basic share button as a learning
I am trying to build an application to simulate some basic spheres moving around.
I am trying to build a basic plugin system like the kind you often
I'm trying to build a basic POP3 mail client in C/++, but I've run
I am completely new to Perl. I am trying to build a basic IRC
I'm trying to build a basic servlet with scala, but I can't seem to
I'm trying to build a basic contact form using jQuery. The markup is essentially
Im trying to build a extremely basic content management system. I want to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.