Hi !
I have à mac m1, and I don't know why my code doesn't work. I'm ussing Arduino IDE2
Could anyone help me please?
Arduino code :
int LED_pin = 13;
void setup()
{
Serial.begin(9600);
pinMode(LED_pin, OUTPUT);
}
void loop()
{
if (Serial.available()) {
int value1 = Serial.read();
if(value1 == 1){
digitalWrite(LED_pin, HIGH);
}
else if (value1 == 0){
digitalWrite(LED_pin, LOW);
}
}
}
J-M-L
February 10, 2023, 10:31am
2
are you sending the number 0 and 1 or the ASCII character '0' and '1' ?
matiasrosales:
if(value1 == 1)
try
if(value1 == '1')
and
else if (value1 == '0'){
that compares the ASCII value of 1 and 0 and not the actual numbers.
J-M-L
February 10, 2023, 11:27am
6
How are they being sent is the question
Does your print command write the binary value or the textual representation
(Or if you want to check replace 0 by '0' in the arduino code, same for 1)
Thanks ! but it does not work ...
Thanks ! but it does not work ... is the same ...
directly from serial b 9600
To see if you are actually receiving anything at all make that:-
if (Serial.available()) {
for(int i = 0; i< 50; i++){
delay(100);
digitalWrite(LED_pin, HIGH);
delay(100);
digitalWrite(LED_pin, LOW);
}
int value1 = Serial.read();
'''
This will rapidly flash the LED when ever something is received.
Thanks but it doesn't work for me either, in this window I should see the values entering?
do you have mac m1 too?
I think it must be a compatibility issue...
matiasrosales:
do you have mac m1 too?
Yes but I don't have MAX MSP, sorry.
And do you know another program with which I can verify if the serial port works?
J-M-L
February 10, 2023, 12:31pm
15
just open the Serial monitor and type 0 and 1 (but check with '0' and '1' in the code) (make sure MAX MSP is not using the Serial port)
try with this code (which works with 0 or '0' and 1 or '1')
const byte ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
switch (Serial.read()) { // returns -1 if there is nothing to read
case '1':
case 1:
digitalWrite(ledPin, HIGH);
break;
case '0':
case 0:
digitalWrite(ledPin, LOW);
break;
}
}
open the Serial monitor at 115200 bauds
type 0 or 1 on the data entry line
side note: are you using Max 8.2 or newer? it has Native Apple Silicon Support
Yes thats work....
The problems is max maybe ... i'm using max 8.5.2
J-M-L
February 10, 2023, 1:14pm
18
that sounds a weird name for the Arduino UNO port.
usually you would have cu. in front of that (cu stands for "calling unit")
what name do you see in the IDE ?
that's my UNO connected to my Mac
I don't have the /dev/cu.USBmodem14101 like you ...
In Port in IDE I see usbmoderm1101 in fact ...
is an Arduino UNO
Board model UNO R3
J-M-L
February 10, 2023, 1:25pm
20
OK possibly just the user interface changing this
as you can upload and play with it from the serial monitor, it means your Mac sees the arduino correctly and the port works.
I don't know enough about Max to dig into the configuration... May be you can post on their forum and find someone who could help?
Thanks, i found the problem is the Satechi USB,
Dont buy it ! ! !
Thanks a lots