Code Help

Hello

I have found some code that i have edited and would like to use on a project that involves building a MIDI controller, using HC-Sr04 sensors. I am fairly new to coding etc and have been experiencing a few error messages. Any help with this would be awesome :slight_smile:

the code is shown below

#include <NewPing.h>

#define SONAR_NUM 4//
#define MAX_DISTANCE 30//
#define PING_INTERVAL 33//

unsigned long pingTimer[SONAR_NUM]; //

unsigned int cm[SONAR_NUM]; //

NewPing (12, 11, MAX_DISTANCE) , //
NewPing (10, 9, MAX_DISTANC) , //
NewPing (7, 6, MAX_DISTANCE),
NewPing (4, 3 MAX_DISTANCE)
} ;

void setup () {
Serial.begin (115200) ;//
pingTimer [0] = millis () + 75;

for (uint8_t i = 1; < SONAR_NUM; i++) //

pingTimer = pingTimer (i - 1] + PING_INTERVAL ;
}
void loop () {

  • for (uint8_t i = 0; i < SONAR_NUM; i++) { //*
    pingTimer = pingTimer [i - 1] = PING_INTERVAL;
    * }*

* void loop() {*
* for (uint8_t i = 0; i < SONAR_NUM; i ++) {//*
_ if (millis() >+ pingTimer { //_

pingTimer += PING_TERMINAL * SONAR_NUM ; //

* if (i == 0 && currentSensor == SONAR_NUM - 1) oneSensorCycle() ;
_ //_
sonar [currentSensor].timer_stop () ;
_ currentSensor = i //_
sonar[currentSensor].ping_timer(echoCheck) ;*

* }*
* }*
* }*
void echoCheck() { //
if (sonar[currentSensor].ping_result/US_ROUNDTRIP_CM;
}
void oneSensorCycle() {
* for (uint8_t i = 0; i < SONAR_NUM; i ++) {
_ serial.printIn (cm) ;*
The error message's that i receive are ;
sketch_apr20d:11: error: expected unqualified-id before numeric constant
sketch_apr20d:11: error: expected `)' before numeric constant
sketch_apr20d:15: error: expected declaration before '}' token
Any help would be brilliant,
Thanks_

NewPing (12, 11, MAX_DISTANCE) , //

Get rid of the useless comments. Have you seen any examples where statements end with commas?

PaulS:

NewPing (12, 11, MAX_DISTANCE) , //

Get rid of the useless comments. Have you seen any examples where statements end with commas?

And repost your code using code tags, the # button above the input box. That way you'll not have some of it in italics and not have o as a variable. Also, it would be a good idea if you hit Ctrl + t in the IDE, to format your code properly, before posting it. That will tell you what some of your errors are.