How do I combine these 2 codes without getting errors?

Codes are in attachments

(deleted)

I'm very new to coding, and I tried combining a newer LED code to my pre-existing RFID code that works perfectly fine. In fact, both codes work great separately, but once I combine them I get compiling errors I just can't figure it out.

"Combine" doesn't work for code. Mixing red and blue paint doesn't get you the middle colour in the rainbow (green) either.

What do you want it to do? How are the two different things going to affect each other?

Have you looked for a tutorial on "combining two sketches"? There are a few good ones online.

So show the combined code and give us the error messages (note the plural) that you get.

MorganS:
"Combine" doesn't work for the code. Mixing red and blue paint doesn't get you the middle color in the rainbow (green) either.

What do you want it to do? How are the two different things going to affect each other?

Have you looked for a tutorial on "combining two sketches"? There are a few good ones online.

Right. The new code that I plan on adding only turn on the Adafruit OLED, but inside of another code. these are my errors.

Tester_Code: 192: error: redefinition of void setup()'
void setup(){
^
Tester_Code: 248: error: redefinition of void setup()'
void setup(){
^

sterretje:
So show the combined code and give us the error messages (note the plural) that you get.

Ok.

/Users/adam/Downloads/Tester_Code/Tester_Code/Tester_Code.ino: In function 'void setup()':
Tester_Code:192: error: redefinition of 'void setup()'
void setup() {
^
/Users/adam/Downloads/Tester_Code/Tester_Code/Tester_Code.ino:20:6: note: 'void setup()' previously defined here
void setup() {
^
/Users/adam/Downloads/Tester_Code/Tester_Code/Tester_Code.ino: In function 'void loop()':
Tester_Code:248: error: redefinition of 'void loop()'
void loop() {
^
/Users/adam/Downloads/Tester_Code/Tester_Code/Tester_Code.ino:39:6: note: 'void loop()' previously defined here
void loop() {
^
exit status 1
redefinition of 'void setup()'

Oops, sorry guys. I fixed the problem.

You still haven't shown us your combined code but from the error messages it looks like you've just pasted one complete program into another without doing any editing. You can't have two setup()s or two loop()s in one sketch.

Here's one clear explanation of what's involved in combining two sketches into one:
http://forum.arduino.cc/index.php?topic=258240.0

Here's another way of looking at it: Merging Code

When you've had a try at making sense of those POST YOUR CODE ATTEMPT! It can be fixed if we can see it. But no-one here is likely to want to guess what you've done just from the error reports.

Well I guess I wasted my time writing this but I might as well post it !

Steve

Oh sorry, I was in class.

The error I was getting was this:

Tester_Code:192: error: redefinition of 'void setup()'
void setup() {
^
But I got it to work because I notice that Arduino doesn't allow 2 void setups or 2 void loops. So, I just took out the void loop/setup content from 1 code and added to the other void loop/setup code. This is the final code.

#include <MFRC522.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_NeoPixel.h>
#include <SPI.h>

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#define SS_PIN 10
#define RST_PIN 9
#define PIN 6
#define N_LEDS 16

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class

MFRC522::MIFARE_Key key;

int code[] = {69,141,8,136}; //This is the stored UID
int codeRead = 0;
String uidString;
void setup() {

Serial.begin(9600);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)

// Clear the buffer.
display.clearDisplay();
display.display();
display.setTextColor(WHITE); // or BLACK);
display.setTextSize(3);
display.setCursor(0,5);
display.print(" S.T.L.");
display.display();
strip.begin();
}

void loop() {
chase(strip.Color(255, 0, 0)); // Red
chase(strip.Color(0, 255, 0)); // Green
chase(strip.Color(0, 0, 255)); // Blue

if( rfid.PICC_IsNewCardPresent())
{
readRFID();
}
delay(100);

}

void readRFID()
{

rfid.PICC_ReadCardSerial();
Serial.print(F("\nPICC type: "));
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
Serial.println(rfid.PICC_GetTypeName(piccType));

// Check is the PICC of Classic MIFARE type
if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
Serial.println(F("Your tag is not of type MIFARE Classic."));
return;
}

clearUID();

Serial.println("Scanned PICC's UID:");
printDec(rfid.uid.uidByte, rfid.uid.size);

uidString = String(rfid.uid.uidByte[0])+" "+String(rfid.uid.uidByte[1])+" "+String(rfid.uid.uidByte[2])+ " "+String(rfid.uid.uidByte[3]);

printUID();

int i = 0;
boolean match = true;
while(i<rfid.uid.size)
{
if(!(rfid.uid.uidByte == code*))*
* {*
* match = false;*
* }*
* i++;*
* }*
* if(match)*
* {*
* Serial.println("\nI know this card!");*
* printUnlockMessage();*
* }else*
* {*
* Serial.println("\nUnknown Card");*
* }*
* // Halt PICC*
* rfid.PICC_HaltA();
_
// Stop encryption on PCD*_
* rfid.PCD_StopCrypto1();
_
}_
void printDec(byte *buffer, byte bufferSize) {
_
for (byte i = 0; i < bufferSize; i++) {_
_ Serial.print(buffer < 0x10 ? " 0" : " ");
Serial.print(buffer, DEC);
}
}_

static void chase(uint32_t c) {
for(uint16_t i=0; i<strip.numPixels()+4; i++) {
_ strip.setPixelColor(i , c); // Draw new pixel*
* strip.setPixelColor(i-4, 0); // Erase pixel a few steps back*
* strip.show();
delay(25);
}
}
void clearUID()
{
display.setTextColor(BLACK); // or BLACK);
display.setTextSize(1);
display.setCursor(30,20);
display.print(uidString);
display.display();
}
void printUID()
{
display.setTextColor(WHITE); // or BLACK);
display.setTextSize(1);
display.setCursor(0,20);
display.print("UID: ");
display.setCursor(30,20);
display.print(uidString);
display.display();
}
void printUnlockMessage()
{
display.display();
display.setTextColor(BLACK); // or BLACK);
display.setTextSize(2);
display.setCursor(10,0);
display.print("RFID Lock");
display.display();*_

* display.setTextColor(WHITE); // or BLACK);*
* display.setTextSize(2);*
* display.setCursor(10,0);*
* display.print("Unlocked");*
* display.display();*

* delay(2000);*

* display.setTextColor(BLACK); // or BLACK);*
* display.setTextSize(2);*
* display.setCursor(10,0);*
* display.print("Unlocked");*
* display.setTextColor(WHITE); // or BLACK);*
* display.setTextSize(2);*
* display.setCursor(10,0);*
* display.print("RFID Lock");*
* display.display();*
* }*

Why is your code partially in italics? Please use code tags when posting code; that will prevent that.
Type
** **[code]** **
before your code.
Type
** **[/code]** **
after your code.