on http://pros.cs.purdue.edu/tutorials/ultrasonic/ it says that in main.h you should put Ultrasonic sonar; and in init you should put sonar = ultrasonicInit(orange_port_number, yellow_port_number); Here’s my main.h
#ifndef MAIN_H_
#define MAIN_H_
#include <API.h>
#ifdef __cplusplus
extern "C" {
#endif
#define claw_piston_pin 2
#define knocker_piston_pin 3
#define left_motor_a 1
#define left_motor_b 2
#define left_motor_c 3
#define right_motor_a 8
#define right_motor_b 9
#define right_motor_c 10
#define arm_motor_a 4
#define arm_motor_b 5
#define arm_motor_c 6
#define arm_motor_d 7
#define left_sonar_orange = 6
#define left_sonar_yellow = 7
#define right_sonar_orange = 5
#define right_sonar_yellow = 4
Ultrasonic left_sonar;
Ultrasonic right_sonar;
void autonomous();
void initializeIO();
void initialize();
void operatorControl();
#ifdef __cplusplus
}
#endif
#endif
and here’s my init.h
#include "main.h"
void initializeIO() {
}
void initialize() {
pinMode(claw_piston_pin, OUTPUT);
pinMode(knocker_piston_pin, OUTPUT);
digitalWrite(knocker_piston_pin, LOW);
digitalWrite(claw_piston_pin, LOW);
left_sonar = ultrasonicInit(left_sonar_orange, left_sonar_yellow);
right_sonar = ultrasonicInit(left_sonar_orange, left_sonar_yellow);
}
and when I try to compile, it gives an error at
left_sonar = ultrasonicInit(left_sonar_orange, left_sonar_yellow);
and
right_sonar = ultrasonicInit(left_sonar_orange, left_sonar_yellow);
that reads “expected expression before ‘=’ token” What did I do wrong and how do I fix it?