Hi, so I'm still very new to the programming side of electronics, and I am currently working on a fix/mod for my BK function generator.
The mechanical switches for wave type selection were damaged, so I've resolved to fix it with a microcontroller. I'm planning to use an attiny85, but so far I'm just using my BBB to test it, and I've run into a problem (I suck at coding.)
const int sinpin = 0; // Sine Wave button
const int squpin = 1; // Square Wave button
const int tripin = 2 ; // Triangle Wave button
const int sine = 12; // Sine Wave output
const int tri = 13; // Triangle Wave output
void setup () {
pinMode(sine, OUTPUT);
pinMode(tri, OUTPUT);
pinMode(sinpin, INPUT);
pinMode(squpin, INPUT);
pinMode(tripin, INPUT);
}
void Sinstate () { digitalRead(sinpin); }
void Squstate () { digitalRead(squpin); }
void Tristate () { digitalRead(tripin); }
void loop(){
pinMode (sinpin, HIGH); //Sets internal pullups
pinMode (squpin, HIGH);
pinMode (tripin, HIGH);
if (Sinstate == HIGH) { //Sine Things
digitalWrite(sine, LOW);
digitalWrite(tri, HIGH); }
else {
if (Sinstate == LOW) {
if (Squstate == LOW) {
digitalWrite(sine, LOW;)
digitalWrite(tri, HIGH); }
if (Tristate == LOW) {
digitalWrite(sine, LOW);
digitalWrite(tri, HIGH); } }
}
if (Squstate == HIGH) { //Square Things
digitalWrite(sine, HIGH);
digitalWrite(tri, HIGH); }
else {
if (Squstate == LOW) {
if (Sinstate == LOW) {
digitalWrite(sine, HIGH);
digitalWrite(tri, HIGH); }
if (Tristate == LOW) {
digitalWrite(sine, HIGH);
digitalWrite(tri, HIGH); } }
}
if (Tristate == HIGH) { //Triangle Things
digitalWrite(sine, HIGH);
digitalWrite(tri, LOW); }
else {
if (Tristate == LOW) {
if (Squstate == LOW) {
digitalWrite(sine, HIGH);
digitalWrite(tri, LOW); }
if (Sinstate == LOW) {
digitalWrite(sine, HIGH);
digitalWrite(tri, LOW); } }
}
}
The intent of the program is to take an input from one of three push button switches (one for each selectable wave type) to set the state of the pins marked "Sine" and "Tri." I am unsure of how to do this more simply (though I'm hoping its not too far above my capabilities). The arduino is meant to send the signals through a transistor to ground the two controlling wires in the function generator.
The above code is currently giving me these errors when I attempt to compile it.
sketch_jun09a.cpp: In function 'void loop()':
sketch_jun09a:28: error: ISO C++ forbids comparison between pointer and integer
sketch_jun09a:34: error: expected `)' before ';' token
sketch_jun09a:34: error: expected primary-expression before ')' token
sketch_jun09a:34: error: expected `;' before ')' token
sketch_jun09a:43: error: ISO C++ forbids comparison between pointer and integer
sketch_jun09a:57: error: ISO C++ forbids comparison between pointer and integer
If you would like it, here is the table for the output selection via grounding on the BK generator. It has internal pullups (on the machine, not affecting the arduino), with low being, of course, when they are grounded.
Control 1 Control 2
Sine Wave High Low
Square Wave Low Low
Triangle/Sawtooth Low High
If you wouldn't mind helping, it would be great!
Thanks.