Trying to sketch a few digital inputs

If somone could just throw a digital input sketch up id appreciate it ive been trying for a while i can change which input numbers and whatnot for my promicro but i would like to addd 5 more didigtal outputs with my analog e brake sketch

// Analog eBrake-Handbrake
// PIN A0 to 10k pot output - Throttle Axis
// Use with Arduino ProMicro.
// Tested and working in DiRT RALLY + ASSETTO CORSA
// 20.1.2017

#include <Joystick.h>

void setup()

{pinMode(A0, INPUT);

{pinMode 9, INPUT; // Set the button as an input
digitalWrite 9, HIGH; // Pull the button high}

const int pinToButtonMap = A0;
int buttonPin = 9; // Set a button to any pin

void loop()

{int pot = analogRead(A0);
int mapped = map(pot,0,1023,0,255);

(digitalRead(9) == 0) // if the button goes low

Keyboard.write(‘z’); // send a ‘z’ to the computer via Keyboard HID
delay 1000; // delay so there aren’t a kajillion z’s

Compiling sketch…
“C:\Users\bling\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2/bin/avr-g++” -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega32u4 -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_MICRO -DARDUINO_ARCH_AVR -DUSB_VID=0x2341 -DUSB_PID=0x8037 ‘-DUSB_MANUFACTURER=“Unknown”’ ‘-DUSB_PRODUCT=“Arduino Micro”’ “-IC:\Users\bling\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\cores\arduino” “-IC:\Users\bling\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\variants\micro” “-ID:\Arduino\libraries\Joystick” “-IC:\Users\bling\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\HID\src” “C:\Users\bling\AppData\Local\Temp\arduino_build_868188\sketch\ANALOG_EBRAKE.ino.cpp” -o “C:\Users\bling\AppData\Local\Temp\arduino_build_868188\sketch\ANALOG_EBRAKE.ino.cpp.o”
ANALOG_EBRAKE:15: error: expected unqualified-id before ‘{’ token

{pinMode 9, INPUT; // Set the button as an input


Using library Joystick in folder: D:\Arduino\libraries\Joystick (legacy)
Using library HID at version 1.0 in folder: C:\Users\bling\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.21\libraries\HID
exit status 1
expected unqualified-id before ‘{’ token

Looks like you need to learn the syntax instead of inventing your own.

You can find digital input examples in the IDE. You’re welcome.

Braces {} are not characters that you just throw in at random. They have a specific purpose. If you don’t understand what they are for you’re not going to have much luck writing C++ code.

BTW if you want to write an if statement the characters i and f are not optional. You can’t just leave bits out and expect the compiler to guess what you meant.


{pinMode(A0, INPUT);

NEVER put anything after the {. Then, you'll never stupidly copy the {, as you did here:

 {pinMode 9, INPUT;  // Set the button as an input

and here:


NEVER put the } on the same line as ANY other code, and you won't look stupid putting two of them on the same line.