UNO family, in particular UNO R3

I am wanting to use my UNO R3 to change the volume of a sine wave input audio signal. The input sine wave audio signal is 100 mili-volts. I want to use some type of single axis tilt sensor to control the input sine wave, making it’s output in a range of zero to 100 mili-volts. Meaning all the way off to all the way wide open. Half of the range would be 50 mili-volts, but I would prefer a log taper—meaning at half tilt of the sensor the output would not be 50 mili-volts. I don’t know if I need a magnetometer, accelerometer, a GMR, or TMR magnetic sensor. I am not interested in using a Hall Effect magnetic sensor. I would like some advice on what type of sensor to use. Would also like some code and hookup examples. Thanks.

you need an accelerometer

Most have a Z-axis which is typical the acceleration in the direction of gravity.

With some gonio you can determine the angle. then map() the degrees to 0 to 100 millivolt.

or map the raw acceleration to 0.100 mV

Is your waveform DC biased, or does half of it exist below 0V? Because if the latter, be aware the ADC of the Uno cannot convert negative signals.

What you probably need to look at is an audio taper digital potentiometer, and control that potentiometer's gain setting. You might need to couple that with a small amplifier, not sure, would depend on externalities of your application.

Oh! That's an excellent idea. I was thinking that the analog manipulation should be done ... outside of the microcontroller, but I was envisioning schemes that would have been much more complex than the digital pot.

Use a physical audio taper pot and hang a weight from the shaft. There's your tilt control!

1 Like

Xfpd, this is a hobby–not a money making project. I want to write the code myself. I will figure out the electronics. Just need pointed in the right direction. Thanks for offering consultancy.

Thanks robtillaart will look into what you said.

Great information camsysca. The audio signal is AC, meaning a sine wave. The digital potentiometer is a great idea. There still needs to be a sensor of some type, because I want the audio signal to be controlled by up and down movement of the sensor.

The suggestion of a digital Pot is great. I am starting to think the best approach is using a GMR magnetic sensor for the signal going to the digital Pot. I actually have a analog circuit working using the GMR magnetic sensor. The only problem I am having with the magnetic GMR analog circuit is making the circuit go to zero, meaning the audio volume going all the way off. With the UNO R3 and the digital pot I think I could better control the end points of the audio signal.

This conflicts with your opening post, and I have read thousands. Many of these topics go on to make Stone Soup.

About your information: You need to describe your tilting.

An FSR (force sensitive resistor) can measure amount of bend/flex/up/down (a form of tilting).

xfpd, I don’t know what Stone Soup is. I said my project is a hobby zero money involved. Yes, I want to write the code myself, but a little help never hurt anything. You never learn anything about coding unless you do it yourself, and make plenty of mistakes. I am aware of bed/flex/up/down sensors, but never used one. I have really been interested in GMR and TMR magnetic sensors. I have a GMR sensor working almost perfectly. It is an analog arrangement, and to make it work perfectly I am going to have to take it digital.

xfpd, GMR and TMR sensors were invented in 2008 and 2014. You said, “You need to describe your tilting.” Really simple—move a magnet toward the GMR or TMR sensor, then move it away from the GMR or TMR sensor. You should look into GMR and TMR sensors. There are many examples of the Arduino being used with these sensors. Several companies make these magnetic sensors, I have been checking out samples from NVE Company in Minnesota, United States.

I believe you've conflated two concepts; though I suspect I know what you mean, I'd like to confirm.

Traditionally, AC means alternating current, which implies a signal that spends at least some portion of it's time below the zero point (i.e. electron flow 'alternates' direction), not just the average point.

A sine wave need not be so, as it may be superimposed upon a DC component. For example, the noise component of a DC power supply may be a 10 mv 60 Hz waveform riding upon a 5V DC component. It is, in that form, not an AC waveform, simply a noise component.

It's still not clear to me what your signal really is, but it really doesn't matter as I haven't the time to explore this further with you today.
Best of luck.

Making it go to zero is possible if you still want to use the GMR

When picking a digital pot be sure and select one that can handle AC input signal. e.g. the Renesas X9314 can accept a +/- AC input, is log taper but only has 32 steps of attenuation.

camsysca, I am aware that an AC signal can be half above and half below a ground. I am also ware that an AC signal can also be totally above a DC bias, or below a DC bias.

jim-p, you said zero is possible using a GMR sensor. I am all ears, but I would like to make a comment. I can get my GMR audio circuit to go to zero, but in doing so I have to lower the maximum output. There needs to be a way to make the GMR audio circuit lower volume, go to zero, without changing the wide open volume. Meaning; If wide open is 100mV I don’t want to lose 20mV getting the circuit to go to zero.

EmilyJane, excellent point! 32 steps is a problem. I have used analog potentiometers with clicks. The last one had 11 clicks and was a 1K potentiometer, so this meant the audio would increase or decrease at the rate of 90.90 ohms each click of the potentiometer. Not a smooth transition of the audio with each click being that dramatic. 32 steps would not be much better.

So just add another gain stage. If the naximum is now 20mV then just add an opamp with a gain of 5 or even more.