Arduino IDE coding error

So i am new to this whole Arduino stuff and i've got a problem.

I bought an Arduino from the internet and a SSD1331.

So to try it out i downloaded a pre-written code from Adafruit (where i ordered my stuff from)
but the code says it has an error: test:22: error: expected ',' or '...' before numeric constant

I did everything just like the website said.

I don't know how to add a code, so i'll just put as an attachment.
Its the code from here: GitHub - adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino: For 0.96" OLEDs in the Adafruit shop

test.pde (8.55 KB)

Works for me. Which version of the Arduino IDE are you using?

I can't see the file you attached cause I'm on a phone but it says it is a .pde file which means it was written for an ancient version of Arduino. I might try to find something more up to date.

pert:
Works for me. Which version of the Arduino IDE are you using?

Arduino 1.8.5

Works for me with 1.8.5. Try downloading the file you attached to your first post and open that downloaded file in the Arduino IDE to make sure you're using the same file I am.

pert:
Works for me with 1.8.5. Try downloading the file you attached to your first post and open that downloaded file in the Arduino IDE to make sure you're using the same file I am.

So i downloaded it, opened it and i still get the same error.

Here's the whole error

Arduino: 1.8.5 (Windows 10), Board: "Adafruit ESP32 Feather, 80MHz, 921600, None"

test:22: error: expected ',' or '...' before numeric constant

#define mosi 11

^

C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries\SPI\src/SPI.h:55:54: note: in expansion of macro 'mosi'

void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);

^

In file included from C:\Users\Francis\Desktop\test\test.pde:40:0:

C:\Program Files (x86)\Arduino\hardware\espressif\esp32\libraries\SPI\src/SPI.h:55:10: error: default argument missing for parameter 3 of 'void SPIClass::begin(int8_t, int8_t, int8_t)'

void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);

^

exit status 1
expected ',' or '...' before numeric constant

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#define mosi 11

you are telling the preprocessor to replace every instance of the string mosi with the numeric constant 11

 void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);

results in this:

 void begin(int8_t sck=-1, int8_t miso=-1, int8_t 11=-1, int8_t ss=-1);

thus:

error: default argument missing for parameter 3

BulldogLowell:

#define mosi 11

you are telling the preprocessor to replace every instance of the string mosi with the numeric constant 11

 void begin(int8_t sck=-1, int8_t miso=-1, int8_t mosi=-1, int8_t ss=-1);

results in this:

 void begin(int8_t sck=-1, int8_t miso=-1, int8_t 11=-1, int8_t ss=-1);

thus:

error: default argument missing for parameter 3

So what does this mean for me?

Don't use #define or any other preprocessor directives unless absolutely necessary. It's a very useful tool when you need it but can also cause lots of confusion, as demonstrated in this thread. In this case there is no benefit to using #define. This is much better:

const byte sclk = 13;
const byte mosi = 11;
const byte cs = 10;
const byte rst = 9;
const byte dc = 8;

pert:
Don't use #define or any other preprocessor directives unless absolutely necessary. It's a very useful tool when you need it but can also cause lots of confusion, as demonstrated in this thread. In this case there is no benefit to using #define. This is much better:

const byte sclk = 13;

const byte mosi = 11;
const byte cs = 10;
const byte rst = 9;
const byte dc = 8;

So this error is now gone, thanks, but i get a new one.
It is not possible to compile it for the Adafruit ESP32 Feather.
Is it possible to rewrite the code or something to use it on the ESP32 Feather?
If yes, what would you need to rewrite?

Here's the error:

Arduino: 1.8.5 (Windows 10), Board: "Adafruit ESP32 Feather, 80MHz, 921600, None"

C:\Users\Francis\Documents\Arduino\libraries\Adafruit-SSD1331\Adafruit_SSD1331.cpp: In member function 'void Adafruit_SSD1331::begin()':

C:\Users\Francis\Documents\Arduino\libraries\Adafruit-SSD1331\Adafruit_SSD1331.cpp:289:21: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment

sclkportreg = portOutputRegister(digitalPinToPort(_sclk));

^

C:\Users\Francis\Documents\Arduino\libraries\Adafruit-SSD1331\Adafruit_SSD1331.cpp:293:20: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment

sidportreg = portOutputRegister(digitalPinToPort(_sid));

^

C:\Users\Francis\Documents\Arduino\libraries\Adafruit-SSD1331\Adafruit_SSD1331.cpp:305:15: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment

csportreg = portOutputRegister(digitalPinToPort(_cs));

^

C:\Users\Francis\Documents\Arduino\libraries\Adafruit-SSD1331\Adafruit_SSD1331.cpp:308:15: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment

rsportreg = portOutputRegister(digitalPinToPort(_rs));

^

exit status 1
Error compiling for board Adafruit ESP32 Feather.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

have you checked out the Adafruit forum? I'm sure that they have folks connecting a Feather to an OLED by now

BulldogLowell:
have you checked out the Adafruit forum? I'm sure that they have folks connecting a Feather to an OLED by now

Yeah i checked there but i couldn't find any useful information on the Huzzah32.

Wow! It’s their product. They are usually awesome at documenting.

BulldogLowell:
Wow! It’s their product. They are usually awesome at documenting.

Yeah, i was on their learn.adafruit website and used the tutorial they had up on there for the product.
But it didn't workout for me.