im new to arduino and trying to help my son with this project
error: exit status 1 a function-definition is not allowed here before '{' token
arduino uno
makerfocus I2C OLED
Maxbotix HRXL range finder
/*
OLED Ultrasonic.ino
Displays results on 128 x 32 OLED display
Uses Adafruit_Sensor.h
Uses Adafruit SSD1306 OLED Library
Uses Adafruit AM2320 Library
Uses Adafruit GFX Graphics Library
*/
// Include Wire Library for I2C
#include <Wire.h>
#include <Adafruit_Sensor.h>
// Include Adafruit Graphics & OLED libraries
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Reset pin not used but needed for library
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
// Start Wire library for I2C
Wire.begin();
// initialize OLED with I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
const int pwPin1 = 2;
long sensor, mm, inches;
// Print a message to the OLED.
void read_sensor (){
sensor = pulseIn(pwPin1, HIGH);
mm = sensor;
inches = (mm/25.4-112);
}
void print_range() {
// Clear the buffer.
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("TANK 1");
//display.setTextColor(WHITE); // 'inverted' text
display.setTextSize(2);
display.setTextColor(WHITE);
display.print("S1");
display.print("=");
display.print(mm);
display.print(" ");
display.print(inches);
display.print(" ");
display.setTextSize(1);
display.println("inches");
display.display();
delay(500);
}
void loop() { print_range();
display.display();
delay(500);
}