RFID code

im fairly new to arduino but i want to jump in at the deep end and want to create a program that when an rfid come into contact with the correct key it turns a green led on. if the led is on an a button is pressed i want it to turn another led on and for every time its pressed after this i want it to turn a different led on for 5 seconds. i want it to do this even if the rfid key isnt present. to turn everythgin off i want you to have to remove the rfid key and hold a button for 5 seconds. i can invision it in my head but its hard to write it down so sorry if its not that clear. id prefer to learn how to do it than for someone to just write the code for me i just dont have a clue where to start.


Draw out a picture of how you see it working and get the individual parts to work. Do the RFID part last, just model that with a switch being high/low to start and the get the other buttons and LEDs working, then add in the RFID reading part last.

You can look at the examples in the IDE to see some basic examples of reading buttons and driving LEDs.
For example, code will have a pre-setup section, a setup() function, and a loop() function.
Presetup is definitions and declarations, setup() runs once, and loop() runs over and over.
(use the </> button for this code box)

// setup pins and variables
byte pin2button = 2; // button connects pin to Gnd when pressed
byte ledPin = 13; // onboard LED, High out = On
void setup(){ // runs once
pinMode (pin2button, INPUT_PULLUP); // pin with internal pullup resistor
pinMode (ledPin, OUTPUT);
void loop(){ //runs over and over
if (digitalRead(pin2button) == LOW){ // button is pressed
digitalWrite (ledPin, HIGH);
else { // button is not pressed
digitalWrite (ledPin, LOW);