Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
Becky Ellis
Published

Wave Generator

This little gadget changes the frequency emitted to a small speaker, allowing you to visualize the changing waveform on an oscilloscope.

BeginnerFull instructions provided1 hour1,960
Wave Generator

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
audio amplifier
×1
Speaker: 0.25W, 8 ohms
Speaker: 0.25W, 8 ohms
×1
Resistor 475 ohm
Resistor 475 ohm
×1
step down voltage regulator
×1
DC adjustable power supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

Schematic

Code

Wave generator

Arduino
#include <avr/interrupt.h> // Use timer interrupt library

/******** Sine wave parameters ********/
#define PI2 6.283185 // 2*PI saves calculation later
#define AMP 127 // Scaling factor for sine wave
#define OFFSET 128 // Offset shifts wave to all >0 values

/******** Lookup table ********/
#define LENGTH 256 // Length of the wave lookup table
void setup() {
  pinMode(9,OUTPUT);
}
void loop() {
  for (int i=0; i<255; i++) {
    analogWrite(9,i);
  delay(10);
  }
}

Credits

Becky Ellis
0 projects • 10 followers
I'm a science teacher and electronics fanatic. :)Moderator for Hackster.io
Contact

Comments

Please log in or sign up to comment.