Help me with my project

i want to add a code so that when i press a key on my keyboard it shows it on a 7 segment display any idees?

int wacht=1000; //a is het plat streepje in het midden. b is de linker boven rechte streep. c is de bovenste platte streep.
                                     //d is de rechter bovenste streep. e is de Linker onderste streep. f is de onderste platte streep. g is de rechter onderste streep.
void setup() {
pinMode(2,OUTPUT); //a 
pinMode(3,OUTPUT); //b
pinMode(4,OUTPUT); //c
pinMode(5,OUTPUT); //d
pinMode(6,OUTPUT); //e
pinMode(7,OUTPUT); //f
pinMode(8,OUTPUT); //g
Serial.begin(9600);
}

void loop() {nul(); delay(wacht); reset();
             een(); delay(wacht); reset(); 
             twee(); delay(wacht); reset(); 
             drie(); delay(wacht); reset(); 
             vier(); delay(wacht); reset(); 
             vijf(); delay(wacht); reset(); 
             zes(); delay(wacht); reset(); 
             zeven(); delay(wacht); reset(); 
             acht(); delay(wacht); reset(); 
             negen(); delay(wacht); reset(); 

}
void nul() {digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void een() {digitalWrite(5,HIGH); digitalWrite(8,HIGH); }

void twee() {digitalWrite(2,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); }

void drie() {digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(2,HIGH); digitalWrite(8,HIGH); digitalWrite(7,HIGH); }

void vier(){digitalWrite(3,HIGH); digitalWrite(2,HIGH); digitalWrite(8,HIGH); digitalWrite(5,HIGH); }

void vijf() { digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH); }

void zes() {digitalWrite(4,HIGH); digitalWrite(3,HIGH); digitalWrite(2,HIGH); digitalWrite(6,HIGH); digitalWrite(8,HIGH); digitalWrite(7,HIGH); }

void zeven() {digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH); }

void acht() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); 
digitalWrite(8,HIGH);}

void negen() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH); digitalWrite(7,HIGH);}

void reset() {digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); digitalWrite(6,LOW); digitalWrite(7,LOW); 
digitalWrite(8,LOW);}

void aaa() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(8,HIGH);}

void bbb() {digitalWrite(3,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void ccc() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH);}

void ddd() {digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void eee() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH);}

void fff() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH);}

void ggg() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void hhh() {digitalWrite(3,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(8,HIGH);}

void iii() {digitalWrite(5,HIGH); digitalWrite(8,HIGH);}

void jjj() {digitalWrite(5,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void lll() {digitalWrite(3,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH);}

void nnn() {digitalWrite(3,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH);}

void ooo() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void ppp() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH);}

void qqq() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(8,HIGH);}

void rrr() {digitalWrite(3,HIGH); digitalWrite(6,HIGH);}

void sss() {digitalWrite(2,HIGH); digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void ttt() {digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH);}

void uuu() {digitalWrite(3,HIGH); digitalWrite(5,HIGH); digitalWrite(6,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

void yyy() {digitalWrite(3,HIGH); digitalWrite(4,HIGH); digitalWrite(5,HIGH); digitalWrite(7,HIGH); digitalWrite(8,HIGH);}

Blokcitaat

Welcome to the forum

How will you be entering the character to be displayed ?
If you intend to use the Serial Monitor you will need to press Return after entering the character.

Is that what you had in mind or do you want the character to be displayed immediately when you press the key on the keyboard ?

Which Arduino board are you using ?

Your current sketch shows ten seven-segment functions, but your mapping from Arduino pin to LED segment is not correct...

animate output image

You have just enough Arduino pins remaining to read eight buttons. https://docs.arduino.cc/built-in-examples/digital/Button/

thx xfpd but i am not using a arduino nano i am using a arduino uno and the mistake u saw is easy to fix thx for the mapping, but do you know the commant that i can use in a if stucture so when i press "o" there will be a signal send to the arduino and than i can make it so that it shows a O on the display and than disapears or changes if i press an other key (i know some buttons like w or m won't work)

i am using a arduino uno. i want to be able to (when my arduino is connected to my pc) send a signal with my key board i also want it to be displayed immediately when i enter the number or letter, and than disapear or change when i fill in an other letter (i would use the space bar to remove the displayed letter of number)

Theses boards uses the same Atmega328 controller and its fully compatible in matter the code.

You need to use any terminal program like Arduino Monitor to send letter from PC to Arduino. To see how to program Arduino to receive letters from PC look for Arduino Serial tutorial.
Please note, that letters from PC keyboard will transfer to Arduino only if PC focus is in Monitor window, not from random PC program

As mentioned in Post #6, you are asking for a keyboard entry in the Serial Monitor to be interpreted by your sketch. (previously, I thought you wanted pushbuttons)

You will want to learn how to use Serial...

A basic introduction ... https://docs.arduino.cc/language-reference/en/functions/communication/serial/read/

An extended introduction... Serial Input Basics - updated

Would it matter if you had to press Return after typing the number or letter ?

Is this pressing Return is the same as pressing Enter (in my PC Keybboard, no Return but Enter key) and also an alternative to clicking on the Send button of Serial Monitor?

Arduino UNO uses 28-pin DIP package (Fig-1) ATmega328 MCU; whereas, Arduino NANO uses 32-pin TQFP package (Fig-2) ATmega328 MCU. Are they same or similar?


Figure-1:


Figure-1: 32-pin TQFP package:

I've noticed that lately you've been arguing for the sake of arguing. I don't want to participate in this.

You are doing it again
Asking questions that you know the answer to

My PC keyboard does not have a key labelled Return or Enter but we both know which key I am referring to and IDE 2.x does not have a Send button

I have been using IDE 2.3.7, but I never noticed the absence of Send button here. I have learnt somthing.

Thank you.

hopefully you know that the same integrated circuit, e.g.ATmega328P can come in a variety of pacakges and that there are a variety of surface mount packages. extra pins often used as extra grounds or power

the Enter key on a keyboard is the '\n' character

but the 1.8 IDE does (top right).
the entered text in the Serial monitor is sent when the Enter key is pressed

no that would be fine i was thinking about using the space bar for that.

most terminal emulators (e.g. putty) send one key/character at a time, as it is pressed

7-segment LED displays have a pretty limited repertoire.
Have you looked at other types?

This is confusing as in IDE 1.8.19, we have to choose Newline option in the Line ending box to send Newlinw character ('\n') as a frame and then click on the Send button or press the Enter key of the PC Keyboard. If pressing Enter send a Newline charcater then the Arduion UNO will receive tow Newline charcaters.

there's the key used by the IDE indicating that the entered text can be sent, not including that key and the characters terminating the text which may include it ('\n') as well as '\r' or neither

and while a c-string is terminated with a nul ('\0') in code, a transmitted "string" of characters sent over a serial interface is not terminated with a nul.

What the "Enter" key sends depends on the software that is running. Take the Serial monitor Line ending setting for example

Yes, I know, but is that relevant ?

Followed by whatever the Line ending is set to