// joystick controls led matrix display//
int we = 0;
int ns = 0;
int z=3;
//Servo servo1;
int led = 13;
long randNumberX;
long randNumberY;
//#include <Servo.h>
#include "LedControl.h"
LedControl lc=LedControl(12,11,10,1);
void setup() {
Serial.begin(9600);
pinMode(z, INPUT);
pinMode(led, OUTPUT);
lc.shutdown(0,false);// turn off power saving, enables display
lc.setIntensity(0,8);// sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
//servo1.attach(3);
}
void loop() {
randNumberX=random(0,8);
randNumberY=random(0,8);
we = analogRead(A1); //x
char x = map(we, 1021, 0, 0, 7); //1021,0,0,7
//servo1.write(x); //0,1023,0,180
ns = analogRead(A0); //y
char y = map(ns, 1021, 0, 7, 0); //1021,0,7,0
z = digitalRead(z); //z
Serial.print("we = ");
Serial.print(we, DEC);
Serial.print(", ns = ");
Serial.print(ns, DEC);
Serial.print(", x = ");
//Serial.print(x, DEC);
Serial.print(", y = ");
// Serial.println(y, DEC);
Serial.print(", z = ");
Serial.println(z, DEC);
lc.clearDisplay(0);
lc.setLed(0,x,y,true);
delay(5);
lc.setLed(0,randNumberX,randNumberY,true);
delay(1000);
lc.setLed(0,randNumberX,randNumberY,false);
delay(1000);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
No comments:
Post a Comment