Hello! I have seen other posts with this problem, but none of them have helped. I have installed 3 different Arduino versions, and have devised that the problem is that I am running Catalina, but I have read that 1.9.0 fixes the issue and it doesn't for me. Any help is appreciated. Thanks!
Here's the program:
/*
Runs HC-04 and SRF-06 and other Ultrasonic Modules
Credits: Arduino Playground - NewPing Library
Also uses HC-SR04 ultrasound sensor from hobbycomponets
/-----( Import needed libraries )-----/
#include <NewPing.h>
#include <HC7Segment.h>
#include <TimedAction.h>
TimedAction timedAction = TimedAction(1000,blink);
/* For the Led display /
const byte u8PinOut_Digit[] = {13,6,5,2};
/ Pin order for segment DIO. The segment order is A,B,C,D,E,F,G,DP /
const byte u8PinOut_Segment[] = {3,7,11,9,8,4,12,10};
/ Create an instance of HC7Segment(). In this example we will be using a 4 digit
common cathode display (CAI5461AH) */
HC7Segment HC7Segment(4, LOW);
/-----Pin connection for Ultrasound sensor-----/
#define TRIGGER_PIN 14
#define ECHO_PIN 15
#define MAX_DISTANCE 500 // Maximum distance we want to ping for (in centimeters).
//Maximum sensor distance is rated at 400-500cm.
/-----( Declare objects )-----/
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
/-----( Declare Variables )-----/
int DistanceCm;
void setup() /****** SETUP: RUNS ONCE ******/
{
//just for debug
Serial.begin(9600);
Serial.println("Debug:arduino and ultrasound sensor");
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
timedAction.check();
HC7Segment.vDisplay_Number(DistanceCm,1);
}//--(end main loop )---
/-----timed action which measures the distance-----/
void blink(){
//delay(50);// Wait 50ms between pings (about 10 pings/sec). 29ms should be the shortest delay between pings.
//DistanceIn = sonar.ping_in();// use if you need Inches
//Serial.print("Ping: ");
delay(50);// Wait 50ms between pings (about 10 pings/sec). 29ms should be the shortest delay between pings.
sonar.ping_median(10);//calculate median of 10 , to minimise error
DistanceCm = sonar.ping_cm();
Serial.print("Ping: ");
Serial.print(DistanceCm);
Serial.println(" cm");
}
Here's the error messages:
Arduino: 1.8.10 (Mac OS X), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
fork/exec /Users/myname/Library/Arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/bin/avr-g++: bad CPU type in executable
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.