Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int prog_data[27] = {15,223,83,95,95,95,77,87,95,77,87,95,77,87,95,77,87,95,94,95,95,125,95,95,95,95,95};
- //int prog_data[27] = {222,222,222,222,222,222,222,206,222,222,94,142,222,94,174,222,210,222,222,222,222,222,222,222,220,222,222};
- //int prog_data[9]= {3,6,9,12,15,18,21,24,27};
- int addr_length = 27;
- int delayTime = 500;
- int redPin = 11;
- int greenPin = 12;
- int WritePin = 2;
- int DataPins[9] = {3,4,5,6,7,8,9,10,11};
- int AddrPins[6] = {A0,A1,A2,A3,A4,A5};
- void setup(){
- Serial.begin(9600);
- pinMode(WritePin, OUTPUT);
- pinMode(greenPin, OUTPUT);
- pinMode(redPin, OUTPUT);
- for(int derp = 0; derp <= 8; derp++){
- pinMode(DataPins[derp], OUTPUT);
- }
- for(int durp = 0; durp <= 5; durp++){
- pinMode(AddrPins[durp], OUTPUT);
- }
- digitalWrite(WritePin, HIGH);
- stat(0);
- }
- void loop(){
- delay(2000);
- stat(1);
- for(int addr = 0; addr <=(addr_length-1); addr++){
- Serial.println(addr);
- output_addr(addr);
- output_data(prog_data[addr]);
- digitalWrite(WritePin, LOW);
- delay(delayTime);
- digitalWrite(WritePin, HIGH);
- }
- stat(0);
- delay(3000);
- }
- void output_addr(int adr){
- for(int lllama=4; lllama>=0; lllama--){
- digitalWrite(AddrPins[lllama], (adr&1<<(4-lllama)?HIGH:LOW));
- }
- }
- void output_data(int dat){
- for(int llama=7; llama>=0; llama--){
- digitalWrite(DataPins[llama], (dat&1<<llama?HIGH:LOW));
- }
- }
- void stat(int state){
- if(state==1){
- digitalWrite(greenPin, LOW);
- digitalWrite(redPin, HIGH);
- }
- else{
- digitalWrite(greenPin, HIGH);
- digitalWrite(redPin, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement