speaker_sound();
void loop() {
tone(speaker, 3200, 500);
delay(575);
tone(speaker, 1900, 300);
delay(575);
}
speaker_sound();
This is a small part of my code, but when I ran it said “expected constructor, destructor, or type conversion before ‘;’ token”. If you think there is something wrong somewhere else, this is the full code.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Arduino.h>
#include <stdio.h>
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
#define LIS3DH_CS 10
Adafruit_LIS3DH lis = Adafruit_LIS3DH();
#define CLICKTHRESHHOLD 20
void setup(void) {
#ifndef ESP8266
while (!Serial) yield(); // will pause Zero, Leonardo, etc until serial console opens
#endif
Serial.begin(9600);
Serial.println("Adafruit LIS3DH Tap Test!");
if (! lis.begin(0x18)) { // change this to 0x19 for alternative i2c address
Serial.println("Couldnt start");
while (1) yield();
}
Serial.println("LIS3DH found!");
lis.setRange(LIS3DH_RANGE_2_G); // 2, 4, 8 or 16 G!
Serial.print("Range = "); Serial.print(2 << lis.getRange());
Serial.println("G");
lis.setClick(2, CLICKTHRESHHOLD);
delay(100);
}
int accelerometer = A5;
int speaker = 13;
speaker_sound();
void loop() {
tone(speaker, 3200, 500);
delay(575);
tone(speaker, 1900, 300);
delay(575);
}
speaker_sound();
void setup() {
pinMode(accelerometer, INPUT);
pinMode(speaker, OUTPUT);
}
void loop() {
uint8_t click = lis.getClick();
if (click == 0) return;
if (! (click & 0x30)) return;
Serial.print("Click detected (0x"); Serial.print(click, HEX); Serial.print("): ");
if (click & 0x10) Serial.print(" single click"), void speaker(void);
if (click & 0x20) Serial.print(" double click");
Serial.println();
}
Thanks in advance!