tag:blogger.com,1999:blog-45118357697081857922024-03-05T06:09:12.413-08:00Adam's Robotics BlogIN620001Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.comBlogger66125tag:blogger.com,1999:blog-4511835769708185792.post-43949660748305492772010-07-21T21:10:00.001-07:002010-07-21T21:38:33.679-07:00Some Of The First RobotsEliza - A computer programmed robot that answered questions with questions. It had 240 lines of code.<br /><br />Unimate Robot - The first industrial robot built in 1961. It took die casting from machines and performed weilding similar to a human task.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.comtag:blogger.com,1999:blog-4511835769708185792.post-91482650024487185372010-07-21T20:56:00.000-07:002010-07-21T21:27:01.805-07:00What Is A Robot?A robot is a machine that can be programmed or controlled to do a specific task such as walking or flying. This is usually powered by electricity and can resemble human tasks.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-32958370019580740092010-06-03T16:27:00.001-07:002010-06-03T16:53:19.613-07:00Task 59 - Data Logging of Light Over 24 HoursI found this was not very accurate as EEPROM was not storing numbers correctly. If a number was over 300 it would not save it into EEPROM, but would save another number all together. However These are my results<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqtMBkdCOfw04g-_KlBfi7WgrnBB2k6aZEgszMlYfdeh0-Up2VWQK7JAWUjgykJoGv9c21e0JeXRGLd4k1khxsI-4S5v19e1X9HPQuokg3xdRGE9bWIVu9ZchG6QBrrTkUns76sHGX2A/s1600/DSC00535.JPG"><img style="WIDTH: 320px; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5478695830077857762" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqtMBkdCOfw04g-_KlBfi7WgrnBB2k6aZEgszMlYfdeh0-Up2VWQK7JAWUjgykJoGv9c21e0JeXRGLd4k1khxsI-4S5v19e1X9HPQuokg3xdRGE9bWIVu9ZchG6QBrrTkUns76sHGX2A/s320/DSC00535.JPG" /></a><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhdg6XqfhBCJFJhU6fEyG6lvi8omM3hdkElkZEbkzOFUIBMFZrkYhe2DQ9OOBUt6ng6uuQRBNKzd08ZxRZkMCwngchaIZnu9e7oF13t1Ri8vgr9HeHY50jq6ArDsIcG1j8d2EvwQgSQg/s1600/1.jpg"><img style="MARGIN: 0px 10px 10px 0px; WIDTH: 81px; FLOAT: left; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5478694853066775362" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhdg6XqfhBCJFJhU6fEyG6lvi8omM3hdkElkZEbkzOFUIBMFZrkYhe2DQ9OOBUt6ng6uuQRBNKzd08ZxRZkMCwngchaIZnu9e7oF13t1Ri8vgr9HeHY50jq6ArDsIcG1j8d2EvwQgSQg/s320/1.jpg" /></a><br /><br />#include <eeprom.h><br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading; // the analog reading from the analog resistor divider<br />int value;<br />int a = 0;<br /><br /><br /><br />void setup() {<br />Serial.begin(9600);<br /><br /><br />for (int i=0; i <25; i++){<br />photocellReading = analogRead(photocellPin);<br />Serial.print("Analog reading = ");<br />Serial.println(photocellReading);<br />EEPROM.write(i, photocellReading);<br />delay(3600000);<br /><br />value = EEPROM.read(i);<br /><br />Serial.print(i);<br />Serial.print("\t");<br />Serial.print(value);<br />Serial.println();<br /><br /><br /><br />}<br /><br /><br />for (int i=0; i <25; i++){<br /><br />value = EEPROM.read(i);<br /><br />Serial.print(i);<br />Serial.print("\t");<br />Serial.print(value);<br />Serial.println();<br /><br /><br /><br />}<br />}<br /><br />void loop(){<br /><br />}<br /><br />Graphed Results (Analog Results, not ones stored in EEPROM):<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigEOkz8vnBkjAaPIR7zZtMCQHmydCF4zZkOYPjV1InHL7i1s_xwmTgMClUMiI9ObBGLoLNBbwbDygn_w0tfvat7fJYGQ-oRQPQQV5vUhdZKqqKJSp-lK9VYWC4Tktzyxa52FziiKrunQ/s1600/3.jpg"><img style="cursor:pointer; cursor:hand;width: 320px; height: 163px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigEOkz8vnBkjAaPIR7zZtMCQHmydCF4zZkOYPjV1InHL7i1s_xwmTgMClUMiI9ObBGLoLNBbwbDygn_w0tfvat7fJYGQ-oRQPQQV5vUhdZKqqKJSp-lK9VYWC4Tktzyxa52FziiKrunQ/s320/3.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5478699167222478306" /></a>Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-40251144546054529442010-06-03T15:44:00.000-07:002010-06-03T15:58:47.084-07:00Major Project - Pong Through One Matrix Display<OBJECT id=BLOG_video-3bb07087d18d4c3e class=BLOG_video_class width=320 height=266 contentId="3bb07087d18d4c3e"></OBJECT><br /><br />/*This is a Pong game used on one Matrix display using analog <br />potentionmeters to move the paddles. This game was helped using <br />similar code from Tom Igoe (for pong) and scrolling message from<br />the website http://www.tinyurl.com/yhwxv6h*/<br /><br /><br /><br /><br />// define the edges of the screen:<br />#define LEFT 0<br />#define RIGHT 7<br />#define TOP 0<br />#define BOTTOM 7<br /><br />int speed = 15; //number of times to repeat each frame<br />int pauseDelay = 500; //microseconds to leave each row on before moving to the next<br />int index = 0; //this is the current charachter in the string being displayed<br />int offset = 0; //this is how many columns it is offset by<br /><br />const int A = 0; const int B = 1; const int C = 2; const int D = 3; const int E = 4;<br />const int F = 5; const int G = 6; const int H = 7; const int I = 8; const int J = 9; <br />const int K = 10; const int L =11; const int M = 12; const int N = 13; const int O = 14; <br />const int P = 15; const int Q =16; const int R = 17; const int S = 18; const int T = 19; <br />const int U = 20; const int V =21; const int W = 22; const int X = 23; const int Y = 24; <br />const int Z = 25; // Letters to be displayed<br /><br />char requestString1[] = " Left Player Wins "; // Request String for left player<br />char requestString2[] = " Right Player Wins "; // Request String for right player<br /> <br />int matrixCount = 0;<br /><br />int rowA[] ={11,14,16,3,13,5,7,9}; //5,6,7,8,9,10,11,12 of matrix<br /><br />//An Array defining which pin each row is attached to<br /> <br />int colA[] = {8,6,4,2,17,15,12,10}; //24,23,22,21,4,3,2,1 of matrix<br /><br /><br />//An Array defining which pin each col is attached to<br /><br /><br />//Punctuation<br />const int COL =26; const int DASH = 27; const int BRA2 = 28; const int _ = 29; const int LINE = 34;<br />const int DOT =36;<br /><br />//Extra Charchters<br />const int FULL =30; const int CHECK = 31; const int A3 = 32; const int TEMP = 33; <br />const int SMILE =35; const int COLDOT = 36;<br /><br /><br />//The array used to hold a bitmap of the display <br />//(if you wish to do something other than scrolling marque change the data in this<br />//variable then display)<br />byte data[] = {0,0,0,0,0,0,0,0}; <br /><br />//The alphabet<br />//Each Charachter is an 8 x 7 bitmap where 1 is on and 0 if off<br />const int _A[] = {B0001000,<br /> B0010100,<br /> B0100010,<br /> B1000001,<br /> B1111111,<br /> B1000001,<br /> B1000001,<br /> B0000000};<br /><br />const int _B[] = {B1111110,<br /> B0100001,<br /> B0100001,<br /> B0111110,<br /> B0100001,<br /> B0100001,<br /> B1111110,<br /> B0000000};<br /><br />const int _C[] = {B0011111,<br /> B0100000,<br /> B1000000,<br /> B1000000,<br /> B1000000,<br /> B0100000,<br /> B0011111,<br /> B0000000};<br /><br />const int _D[] = {B1111100,<br /> B0100010,<br /> B0100001,<br /> B0100001,<br /> B0100001,<br /> B0100010,<br /> B1111100,<br /> B0000000};<br /><br />const int _E[] = {B1111111,<br /> B1000000,<br /> B1000000,<br /> B1111100,<br /> B1000000,<br /> B1000000,<br /> B1111111,<br /> B0000000};<br /><br />const int _F[] = {B1111111,<br /> B1000000,<br /> B1000000,<br /> B1111100,<br /> B1000000,<br /> B1000000,<br /> B1000000,<br /> B0000000};<br /><br />const int _G[] = {B0011111,<br /> B0100000,<br /> B1000000,<br /> B1001111,<br /> B1000001,<br /> B0100001,<br /> B0011111,<br /> B0000000};<br /><br />const int _H[] = {B1000001,<br /> B1000001,<br /> B1000001,<br /> B1111111,<br /> B1000001,<br /> B1000001,<br /> B1000001,<br /> B0000000};<br /><br />const int _I[] = {B1111111,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B1111111,<br /> B0000000};<br /><br />const int _J[] = {B0001111,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B1000001,<br /> B0111110,<br /> B0000000};<br /><br />const int _K[] = {B1000011,<br /> B1000100,<br /> B1001000,<br /> B1110000,<br /> B1001000,<br /> B1000100,<br /> B1000011,<br /> B0000000};<br /><br />const int _L[] = {B1000000,<br /> B1000000,<br /> B1000000,<br /> B1000000,<br /> B1000000,<br /> B1000000,<br /> B1111111,<br /> B0000000};<br /><br />const int _M[] = {B1110110,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B0000000};<br /><br />const int _N[] = {B1000001,<br /> B1100001,<br /> B1010001,<br /> B1001001,<br /> B1000101,<br /> B1000011,<br /> B1000001,<br /> B0000000};<br /><br />const int _O[] = {B0011100,<br /> B0100010,<br /> B1000001,<br /> B1001001,<br /> B1000001,<br /> B0100010,<br /> B0011100,<br /> B0000000};<br /><br />const int _P[] = {B1111110,<br /> B0100001,<br /> B0100001,<br /> B0111110,<br /> B0100000,<br /> B0100000,<br /> B0100000,<br /> B0000000};<br /><br />const int _Q[] = {B0011100,<br /> B0100010,<br /> B1000001,<br /> B1000001,<br /> B1000101,<br /> B0100010,<br /> B0011101,<br /> B0000000};<br /><br />const int _R[] = {B1111110,<br /> B0100001,<br /> B0100001,<br /> B0101110,<br /> B0100100,<br /> B0100010,<br /> B0100001,<br /> B0000000};<br /><br />const int _S[] = {B0111111,<br /> B1000000,<br /> B1000000,<br /> B0111110,<br /> B0000001,<br /> B0000001,<br /> B1111110,<br /> B0000000};<br /><br />const int _T[] = {B1111111,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0000000};<br /><br />const int _U[] = {B1000001,<br /> B1000001,<br /> B1000001,<br /> B1000001,<br /> B1000001,<br /> B1000001,<br /> B0111110,<br /> B0000000};<br /><br />const int _V[] = {B1000001,<br /> B1000001,<br /> B1000001,<br /> B1000001,<br /> B0100010,<br /> B0010100,<br /> B0001000,<br /> B0000000};<br /> <br />const int _W[] = {B1000001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B1001001,<br /> B0110110,<br /> B0000000};<br /><br />const int _X[] = {B1000001,<br /> B0100010,<br /> B0010100,<br /> B0001000,<br /> B0010100,<br /> B0100010,<br /> B1000001,<br /> B0000000};<br /><br />const int _Y[] = {B1000001,<br /> B0100010,<br /> B0010100,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0001000,<br /> B0000000};<br /><br />const int _Z[] = {B1111111,<br /> B0000010,<br /> B0000100,<br /> B0111110,<br /> B0010000,<br /> B0100000,<br /> B1111111,<br /> B0000000};<br /><br />const int _COL[] = {B0000000,<br /> B0011000,<br /> B0011000,<br /> B0000000,<br /> B0011000,<br /> B0011000,<br /> B0000000,<br /> B0000000};<br /><br />const int _DASH[] = {B0000000,<br /> B0000000,<br /> B0000000,<br /> B0111110,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000};<br /><br />const int _BRA2[] = {B0010000,<br /> B0001000,<br /> B0000100,<br /> B0000100,<br /> B0001000,<br /> B0010000,<br /> B0000000,<br /> B0000000}; <br /><br />const int __[] = {B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000};<br /><br />const int _FULL[] = {B1111111,<br /> B1111111,<br /> B1111111,<br /> B1111111,<br /> B1111111,<br /> B1111111,<br /> B1111111,<br /> B1111111}; <br /><br />const int _CHECK[] = {B1010101,<br /> B0101010,<br /> B1010101,<br /> B0101010,<br /> B1010101,<br /> B0101010,<br /> B1010101,<br /> B0000000};<br /> <br />const int _A3[] = {B0111110,<br /> B0000001,<br /> B0000001,<br /> B0001111,<br /> B0000001,<br /> B1000001,<br /> B0111110,<br /> B0000000};<br /><br />const int _TEMP[] = {B0000011,<br /> B0011111,<br /> B0111111,<br /> B1111110,<br /> B1111111,<br /> B0011111,<br /> B0000011,<br /> B0000000};<br /><br />const int _LINE[] = {B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000001,<br /> B0000000}; <br /> <br />const int _SMILE[] = {B1100110,<br /> B1100110,<br /> B0000000,<br /> B0011100,<br /> B1000001,<br /> B0100010,<br /> B0011100,<br /> B0000000}; <br /> <br /><br />const int _DOT[] = {B0000000,<br /> B0000000,<br /> B0000000,<br /> B0000000,<br /> B1100000,<br /> B1100000,<br /> B0000000,<br /> B0000000}; <br /> <br />const int _COLDOT[] = {B0000000,<br /> B0110000,<br /> B0110000,<br /> B0000000,<br /> B0110011,<br /> B0110011,<br /> B0000000,<br /> B0000000}; <br /><br />//Load the bitmap charachters into an array (each charachters position corresponds to its previously defined index (ie _A (a's bitmap) <br />//is at index 0 and A = 0 so letters[A] will return the 'A' bitmap)<br />const int* letters[] = {_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,_COL,_DASH,_BRA2,__, _FULL, _CHECK, _A3, _TEMP, _LINE, _SMILE, _DOT, _COLDOT};<br /><br />//Setup runs once when power is applied<br /><br /><br /><br />int pixels[8][8]; // 2-dimensional array of pixels<br /><br />// 2-dimensional array of row pin numbers (for two matrices):<br />int row[1][8] = {11,14,16,3,13,5,7,9}; //5,6,7,8,9,10,11,12 of matrix<br /><br />// 2-dimensional array of column pin numbers (for two matrices):<br />int col[1][8] = {8,6,4,2,17,15,12,10}; //24,23,22,21,4,3,2,1 of matrix<br /><br />int ballX = 3; // X position of the ball <br />int ballY = 4; // Y position of the ball<br />int ballDirectionY = 1; // X direction of the ball<br />int ballDirectionX = 1; // Y direction of the ball<br />int lCount = 0; // count score for left paddle<br />int rCount = 0; // count score for right paddle<br /><br />int rightPaddleY = 0; // X position of the center of the right paddle<br />int leftPaddleY = 0; // Y position of the center of the right paddle<br /><br />long timeStamp = 0; // time stamp to control the pauses between ball moves<br />long interval = 250; // interval between ball moves, in milliseconds<br />boolean gamePaused = false; // state of the game<br /><br />void setup() {<br /> // initialize the I/O pins as outputs:<br /><br /> // iterate over the matrix:<br /> for (int thisMatrix = 0; thisMatrix < 1; thisMatrix++) {<br /> // iterate over the pins:<br /> for (int thisPin = 0; thisPin < 8; thisPin++) {<br /> // initialize the output pins:<br /> pinMode(col[thisMatrix][thisPin], OUTPUT); <br /> pinMode(row[thisMatrix][thisPin], OUTPUT); <br /> // take the col pins (i.e. the cathodes) high to ensure that<br /> // the LEDS are off: <br /> digitalWrite(col[thisMatrix][thisPin], HIGH); <br /> }<br /> <br /> }<br />newGame();<br /> <br />}<br /><br />void loop() {<br /> // read input:<br /> readSensors();<br /> // move the ball:<br /> if (gamePaused) {<br /> if (millis() - timeStamp > interval*10) {<br /> // if enough time has passed, start the game again:<br /> gamePaused = false;<br /> }<br /> } <br /> // if the game isn't paused, and enough time between ball moves<br /> // has passed, move the ball and update the timestamp:<br /> else {<br /> if (millis() - timeStamp > interval) {<br /> moveBall();<br /> timeStamp = millis();<br /> }<br /> }<br /> // draw the screen:<br /> refreshScreen();<br />}<br /><br />void newGame() {<br /> <br /> for (int thisMatrix = 0; thisMatrix < 1; thisMatrix++) {<br /> // iterate over the pins:<br /> for (int thisPin = 0; thisPin < 8; thisPin++) {<br /> digitalWrite(row[thisMatrix][thisPin], HIGH); <br /> digitalWrite(col[thisMatrix][thisPin], LOW); <br /> }<br /> delay(200); <br /> for (int thisPin = 0; thisPin < 8; thisPin++) {<br /> digitalWrite(row[thisMatrix][thisPin], LOW); <br /> digitalWrite(col[thisMatrix][thisPin], LOW); <br /> }<br /> delay(100); <br /> <br /> }<br /> <br /> <br /> <br /> <br />} <br /><br />void readSensors() {<br /> // set the left paddle to off:<br /> setPaddle(LEFT, leftPaddleY, HIGH);<br /> // set the right paddle to off:<br /> setPaddle(RIGHT, rightPaddleY, HIGH);<br /><br /> // read the sensors for X and Y values:<br /> leftPaddleY = map(analogRead(4), 0, 1023, 0, 7);<br /> rightPaddleY = map(analogRead(5), 0, 1023, 0, 7);<br /><br /> // set the left paddle to on:<br /> setPaddle(LEFT, leftPaddleY, LOW);<br /> // set the right paddle to on:<br /> setPaddle(RIGHT, rightPaddleY, LOW);<br />}<br /><br />void setPaddle(int paddleX, int paddleY, int state) {<br /> // set the last right paddle to on:<br /> pixels[paddleX][paddleY] = state;<br /> // set the bottom pixel of the paddle:<br /> if (paddleY < BOTTOM) {<br /> pixels[paddleX][paddleY+1] = state; <br /> }<br /><br /> // set the top pixel of the paddle:<br /> if (paddleY > TOP) {<br /> pixels[paddleX][paddleY-1] = state; <br /> }<br />}<br /><br />void moveBall() {<br /> // check to see if the ball is in the horizontal range <br /> // of the paddles:<br /><br /> // right:<br /> if (ballX >= RIGHT - 1) {<br /> // if the ball's next Y position is between <br /> // the top and bottom of the paddle, reverse its X direction:<br /> if ((ballY + ballDirectionY >= rightPaddleY - 1) <br /> && (ballY + ballDirectionY <= rightPaddleY +1)) {<br /> // reverse the ball horizontal direction:<br /> ballDirectionX = -ballDirectionX; <br /> }<br /> }<br /><br /> // left:<br /> if (ballX <= LEFT + 1) {<br /> // if the ball's next Y position is between <br /> // the top and bottom of the paddle, reverse its X direction:<br /> if ((ballY + ballDirectionY >= leftPaddleY -1 ) <br /> && (ballY + ballDirectionY <= leftPaddleY +1 )) {<br /> // reverse the ball horizontal direction:<br /> ballDirectionX = -ballDirectionX; <br /> }<br /> }<br /><br /> // if the ball goes off the screen bottom,<br /> // reverse its Y direction:<br /> if (ballY == BOTTOM) {<br /> ballDirectionY = -ballDirectionY;<br /> }<br /> // if the ball goes off the screen top, <br /> // reverse its X direction:<br /> if (ballY == TOP) {<br /> ballDirectionY = -ballDirectionY;<br /> }<br /><br /> // clear the ball's previous position:<br /> pixels[ballX][ballY] = HIGH;<br /><br /> // if the ball goes off the screen left or right:<br /> if ((ballX == LEFT) || (ballX == RIGHT)) {<br /> if (ballX == LEFT) {<br /> lCount = lCount+1;<br /> if (lCount == 3){<br /> matrixCount = 1;<br /> for (int i=0; i<136; i++){<br /> updateMatrix(); <br /> } <br /> lCount = 0;<br /> rCount = 0; <br /> newGame();<br /> }<br /> <br /> }else if (ballX==RIGHT){<br /> rCount = rCount+1; <br /> if (rCount == 3){<br /> matrixCount = 2;<br /> for (int i=0; i<144; i++){<br /> updateMatrix(); <br /> } <br /> lCount = 0;<br /> rCount = 0; <br /> newGame(); <br /> }<br /> }<br /><br /> // reset the ball:<br /> ballX = 4;<br /> ballY = 4;<br /> // pause and note the time you paused:<br /> gamePaused = true;<br /> timeStamp = millis();<br /> }<br /> // increment the ball's position in both directions:<br /> ballX = ballX + ballDirectionX;<br /> ballY = ballY + ballDirectionY;<br /><br /> // if the game isn't paused, set the ball<br /> // in its new position:<br /> if (!gamePaused) {<br /> // set the new position:<br /> pixels[ballX][ballY] = LOW; <br /> }<br />}<br /><br />void refreshScreen() {<br /> // iterate over the matrices:<br /> for (int thisMatrix = 0; thisMatrix < 1; thisMatrix++) {<br /> // iterate over the rows (anodes):<br /> for (int thisRow = 0; thisRow < 8; thisRow++) {<br /> // take the row pin (anode) high:<br /> digitalWrite(row[thisMatrix][thisRow], HIGH);<br /> // iterate over the cols (cathodes):<br /> for (int thisCol = 0; thisCol < 8; thisCol++) {<br /> // get the state of the current pixel;<br /> int thisPixel = pixels[thisRow+ (thisMatrix * 8)][thisCol];<br /> // when the row is HIGH and the col is LOW,<br /> // the LED where they meet turns on:<br /> digitalWrite(col[thisMatrix][thisCol], thisPixel);<br /> // turn the pixel off:<br /> digitalWrite(col[thisMatrix][thisCol], HIGH); <br /> }<br /> // take the row pin low to turn off the whole row:<br /> digitalWrite(row[thisMatrix][thisRow], LOW);<br /> }<br /> }<br />}<br />void updateMatrix(){<br /> loadSprite();<br /> showSprite(speed);<br />}<br /><br />const int powers[] = {1,2,4,8,16,32,64,128};<br /><br />//Loads the current scroll state frame into the data[] display array<br />void loadSprite(){<br /> if (matrixCount == 1){<br /> int currentChar = getChar(requestString1[index]);<br /> int nextChar = getChar(requestString1[index+1]); <br /> <br /> for(int row=0; row < 8; row++){ //iterate through each row<br /> data[row] = 0; //reset the row we're working on<br /> for(int column=0; column < 8; column++){ //iterate through each column<br /> data[row] = data[row] + ((powers[column] & (letters[currentChar][row] << offset))); //loads the current charachter offset by offset pixels <br /> data[row] = data[row] + (powers[column] & (letters[nextChar][row] >> (8-offset) )); //loads the next charachter offset by offset pixels<br /> }<br /> }<br /> offset++; //increment the offset by one row<br /> if(offset==8){offset = 0; index++; if(index==sizeof(requestString1)-2){index=0;}} //if offset is 8 load the next charachter pair for the next time through<br /> <br /> <br /> <br /> <br /> }else if (matrixCount == 2){<br /> int currentChar = getChar(requestString2[index]);<br /> int nextChar = getChar(requestString2[index+1]); <br /> <br /> for(int row=0; row < 8; row++){ //iterate through each row<br /> data[row] = 0; //reset the row we're working on<br /> for(int column=0; column < 8; column++){ //iterate through each column<br /> data[row] = data[row] + ((powers[column] & (letters[currentChar][row] << offset))); //loads the current charachter offset by offset pixels <br /> data[row] = data[row] + (powers[column] & (letters[nextChar][row] >> (8-offset) )); //loads the next charachter offset by offset pixels<br /> }<br /> }<br /> offset++; //increment the offset by one row<br /> if(offset==8){offset = 0; index++; if(index==sizeof(requestString2)-2){index=0;}} //if offset is 8 load the next charachter pair for the next time through<br /> <br /> <br /> <br /> <br /><br /> }<br />}<br />void showSprite(int speed2){<br /> for(int iii = 0; iii < speed2; iii++){ //show the current frame speed2 times<br /> for(int column = 0; column < 8; column++){ //iterate through each column<br /> for(int i = 0; i < 8; i++){ <br /> digitalWrite(rowA[i], LOW); //turn off all row pins <br /> }<br /> for(int i = 0; i < 8; i++){ //Set only the one pin<br /> if(i == column){ digitalWrite(colA[i], LOW);} //turns the current row on<br /> else{ digitalWrite(colA[i], HIGH); }//turns the rest of the rows off<br /> }<br /><br /> for(int row = 0; row < 8; row++){ //iterate through each pixel in the current column<br /> int bit = (data[column] >> row) & 1;<br /> if(bit == 1){ <br /> digitalWrite(rowA[row], HIGH); //if the bit in the data array is set turn the LED on<br /> }<br /><br /> }<br /> delayMicroseconds(pauseDelay); //leave the column on for pauseDelay microseconds (too high a delay causes flicker)<br /> } <br /> }<br />}<br /><br />//returns the index of a given charachter<br />//for converting from a string to a lookup in our array of charachter bitmaps<br />int getChar(char charachter){<br /> int returnValue = Z;<br /> switch(charachter){<br /> case 'A': returnValue = A; break;<br /> case 'a': returnValue = A; break;<br /> case 'B': returnValue = B; break;<br /> case 'b': returnValue = B; break;<br /> case 'C': returnValue = C; break;<br /> case 'c': returnValue = C; break;<br /> case 'D': returnValue = D; break;<br /> case 'd': returnValue = D; break;<br /> case 'E': returnValue = E; break;<br /> case 'e': returnValue = E; break;<br /> case 'F': returnValue = F; break;<br /> case 'f': returnValue = F; break;<br /> case 'G': returnValue = G; break;<br /> case 'g': returnValue = G; break;<br /> case 'H': returnValue = H; break;<br /> case 'h': returnValue = H; break;<br /> case 'I': returnValue = I; break;<br /> case 'i': returnValue = I; break;<br /> case 'J': returnValue = J; break;<br /> case 'j': returnValue = J; break;<br /> case 'K': returnValue = K; break;<br /> case 'k': returnValue = K; break;<br /> case 'L': returnValue = L; break;<br /> case 'l': returnValue = L; break;<br /> case 'M': returnValue = M; break;<br /> case 'm': returnValue = M; break;<br /> case 'N': returnValue = N; break;<br /> case 'n': returnValue = N; break;<br /> case 'O': returnValue = O; break;<br /> case 'o': returnValue = O; break;<br /> case 'P': returnValue = P; break;<br /> case 'p': returnValue = P; break;<br /> case 'Q': returnValue = Q; break;<br /> case 'q': returnValue = Q; break;<br /> case 'R': returnValue = R; break;<br /> case 'r': returnValue = R; break;<br /> case 'S': returnValue = S; break;<br /> case 's': returnValue = S; break;<br /> case 'T': returnValue = T; break;<br /> case 't': returnValue = T; break;<br /> case 'U': returnValue = U; break;<br /> case 'u': returnValue = U; break;<br /> case 'V': returnValue = V; break;<br /> case 'v': returnValue = V; break;<br /> case 'W': returnValue = W; break;<br /> case 'w': returnValue = W; break;<br /> case 'X': returnValue = X; break;<br /> case 'x': returnValue = X; break;<br /> case 'Y': returnValue = Y; break;<br /> case 'y': returnValue = Y; break;<br /> case 'Z': returnValue = Z; break;<br /> case 'z': returnValue = Z; break;<br /> case ' ': returnValue = _; break;<br /> case '3': returnValue = A3; break;<br /> case '<': returnValue = TEMP; break;<br /> case '*': returnValue = FULL; break;<br /> case '|': returnValue = LINE; break; <br /> case '_': returnValue = _; break; <br /> case ':': returnValue = COL; break; <br /> case '-': returnValue = DASH; break; <br /> case ')': returnValue = BRA2; break; <br /> case '%': returnValue = SMILE; break; <br /> case '.': returnValue = DOT; break; <br /> case '^': returnValue = COLDOT; break; <br /> }<br /> return returnValue;<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-84257547523897561482010-05-30T16:05:00.000-07:002010-05-30T16:26:03.370-07:00Task 58 - Finding Average & Biggest Number With Suitable Message#include EEPROM.h<br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading;// the analog reading from the analog resistor divider<br />int value;<br />int a = 0;<br />int smallest = 0;<br />int biggest = 0;<br />float average = 0;<br /><br /><br /><br />void setup() { <br />Serial.begin(9600); <br /><br /><br />for (int i=0; i <10; i++){<br /> photocellReading = analogRead(photocellPin);<br /> if (photocellReading < smallest){<br /> smallest = photocellReading;<br /> }<br /> if (photocellReading > biggest){<br /> biggest = photocellReading;<br /> }<br /> average = average + photocellReading;<br /> EEPROM.write(i, photocellReading);<br /> delay(500);<br />}<br /><br />for (int i=0; i <10; i++){ <br /> value = EEPROM.read(a);<br /> Serial.print(a);<br /> Serial.print("\t");<br /> Serial.print(value);<br /> Serial.println();<br /><br /> a = a + 1;<br /><br /> if (a == 10){<br /> a = 0;<br /> delay(500);<br /> }<br /> }<br />Serial.println("The Smallest Value Was: " + smallest); // displays smallest value<br />Serial.println("The Biggest Value Was: " + biggest); // displays biggest value<br />average = average/10; // calculates mean<br />Serial.println("The Average/Mean Was: " + average); // displays average value<br />}<br /><br />void loop(){<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-19777406558912601442010-05-30T15:58:00.000-07:002010-05-30T16:28:02.287-07:00Task 57 - Finding smallest Value With Suitable Message.#include EEPROM.h<br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading;// the analog reading from the analog resistor divider<br />int value;<br />int a = 0;<br />int smallest = 0;<br /><br /><br /><br />void setup() { <br />Serial.begin(9600); <br /><br /><br />for (int i=0; i <10; i++){<br />photocellReading = analogRead(photocellPin);<br />if (photocellReading < smallest){<br />smallest = photocellReading;<br />}<br />EEPROM.write(i, photocellReading);<br />delay(500);<br />}<br /><br />for (int i=0; i <10; i++){ <br />value = EEPROM.read(a);<br /><br />Serial.print(a);<br />Serial.print("\t");<br />Serial.print(value);<br />Serial.println();<br /><br />a = a + 1;<br /><br />if (a == 10){<br />a = 0;<br />delay(500);<br />}<br />}<br />Serial.println("The Smallest Value Was: " + smallest);<br />}<br /><br />void loop(){<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-66981299874476259022010-05-16T16:42:00.001-07:002010-05-30T16:26:59.498-07:00Task 56 - Data Logging to EEPROM#include EEPROM.h<br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading;// the analog reading from the analog resistor divider];<br />//int mySamples[10];<br />int value;<br />int a = 0;<br /><br /><br /><br />void setup() { <br />Serial.begin(9600); <br /><br /><br />for (int i=0; i <10; i++){<br /> photocellReading = analogRead(photocellPin);<br /> //mySamples[i] = (photocellReading); <br /> EEPROM.write(i, photocellReading);<br /> delay(500);<br /> }<br /> <br />for (int i=0; i <10; i++){ <br /> value = EEPROM.read(a);<br /><br /> Serial.print(a);<br /> Serial.print("\t");<br /> Serial.print(value);<br /> Serial.println();<br /><br /> a = a + 1;<br /><br /> if (a == 10){<br /> a = 0;<br /> delay(500);<br /> }<br />}<br />}<br /><br />void loop(){<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-85629130896255948652010-05-16T16:27:00.000-07:002010-05-16T16:28:17.507-07:00Task 55 - Data Logging with Arrayint photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading;// the analog reading from the analog resistor divider];<br />int mySamples[10];<br /><br />void setup() { <br />Serial.begin(9600); <br /><br /><br />for (int i=0; i <10; i++){<br /> photocellReading = analogRead(photocellPin);<br /> mySamples[i] = (photocellReading); <br /> delay(500);<br /> }<br /><br />for (int i=0; i <10; i++){<br /> Serial.print("Analog reading = ");<br /> Serial.println(mySamples[i]);<br />} <br />}<br /><br />void loop(){<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-53832301334758254272010-05-16T16:15:00.001-07:002010-05-16T16:24:36.816-07:00Task 54 - Data loggingint photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading; // the analog reading from the analog resistor divider<br /><br />void setup() { <br />Serial.begin(9600); <br /><br /><br />for (int i=0; i <10; i++){<br /> photocellReading = analogRead(photocellPin); <br /> Serial.print("Analog reading = ");<br /> Serial.println(photocellReading); <br /> delay(500);<br /> }<br />}<br /><br />void loop(){<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-36975127029978334502010-05-09T02:50:00.000-07:002010-05-09T03:57:48.673-07:00Minor Project - Keyboard input, Matrix Display Output<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dzoCDBXCEdexj5KtLvEKg_ACbNR-Ig0K-HW5fjUXKSgCuPWLbhZdx30JBtv3KSD4cP-McJVCv3nsBxQfQKhjA' class='b-hbp-video b-uploaded' frameborder='0'></iframe><br /><br /><br />or <a href="http://www.youtube.com/watch?v=ysy3eYsyBtQ">http://www.youtube.com/watch?v=ysy3eYsyBtQ</a><br /><br /><br />The below code is what I used for my minor project:<br /><br />#include "ps2.h"<br /><br />#define PS2_KC_BKSP 0x08<br />#define PS2_KC_UP 0x81<br />#define PS2_KC_DOWN 0x82<br />#define PS2_KC_LEFT 0x83<br />#define PS2_KC_RIGHT 0x84<br />#define PS2_KC_PGDN 0x85<br />#define PS2_KC_PGUP 0x86<br />#define PS2_KC_END 0x87<br />#define PS2_KC_HOME 0x88<br />#define PS2_KC_INS 0x89<br />#define PS2_KC_DEL 0x8A<br />#define PS2_KC_ESC 0x8B<br />#define PS2_KC_CLON 0x8C // caps_lock on<br />#define PS2_KC_CLOFF 0x8D // caps_lock off<br /><br />/*<br />* Pin 2 is the ps2 data pin, pin 3 is the clock pin<br />*/<br /><br />PS2 kbd(3, 2);<br />bool ps2Keyboard_release = false;<br />bool ps2Keyboard_extend = false;<br />bool cmd_ack_byte_ok = false;<br />bool ps2Keyboard_shift = false;<br />bool ps2Keyboard_alt = false;<br />bool ps2Keyboard_caps_lock = false;<br />bool ps2Keyboard_ctrl = false;<br /><br />byte ps2Keyboard_CharBuffer = 0;<br /><br />byte code;<br /><br /><br />int count = 0;<br /><br />int speed = 20; //number of times to repeat each frame<br />int pauseDelay = 500; //microseconds to leave each row on before moving to the next<br /><br />//byte result = ps2Keyboard_CharBuffer;<br />char incomingByte;<br />//char str1[] = " ";<br /><br />char requestString[100];//The string to display<br /><br />char character; //to change the message in code you right yourself simply<br />//change this data and reset index and offset to 0<br />//Variables used for scrolling (both start at 0<br />int index = 0; //this is the current charachter in the string being displayed<br />int offset = 0; //this is how many columns it is offset by<br /><br />//Pin Definitions<br />int rowA[] ={11,14,16,18,13,5,7,9}; //5,6,7,8,9,10,11,12 of matrix<br />//{11,14,16,18,3,5,7,9};//An Array defining which pin each row is attached to<br />//(rows are common anode (drive HIGH))<br />int colA[] = {8,6,4,19,17,15,12,10}; //24,23,22,21,4,3,2,1 of matrix<br />//{10,12,15,17,2,4,6,8}; //An Array defining which pin each column is attached to<br />//(columns are common cathode (drive LOW))<br /><br />//Constants defining each charachters position in an array of integer arrays<br />//Letters<br />const int A = 0; const int B = 1; const int C = 2; const int D = 3; const int E = 4;<br />const int F = 5; const int G = 6; const int H = 7; const int I = 8; const int J = 9;<br />const int K = 10; const int L =11; const int M = 12; const int N = 13; const int O = 14;<br />const int P = 15; const int Q =16; const int R = 17; const int S = 18; const int T = 19;<br />const int U = 20; const int V =21; const int W = 22; const int X = 23; const int Y = 24;<br />const int Z = 25;<br /><br />//Punctuation<br />const int COL =26; const int DASH = 27; const int BRA2 = 28; const int _ = 29; const int LINE = 34;<br />const int DOT =36;<br /><br />//Extra Charchters<br />const int FULL =30; const int CHECK = 31; const int A3 = 32; const int TEMP = 33;<br />const int SMILE =35; const int COLDOT = 36;<br /><br />//char requestString[] = "";<br />//The array used to hold a bitmap of the display<br />//(if you wish to do something other than scrolling marque change the data in this<br />//variable then display)<br />byte data[] = {0,0,0,0,0,0,0,0};<br /><br />//The alphabet<br />//Each Charachter is an 8 x 7 bitmap where 1 is on and 0 if off<br />const int _A[] = {B0001000,<br />B0010100,<br />B0100010,<br />B1000001,<br />B1111111,<br />B1000001,<br />B1000001,<br />B0000000};<br /><br />const int _B[] = {B1111110,<br />B0100001,<br />B0100001,<br />B0111110,<br />B0100001,<br />B0100001,<br />B1111110,<br />B0000000};<br /><br />const int _C[] = {B0011111,<br />B0100000,<br />B1000000,<br />B1000000,<br />B1000000,<br />B0100000,<br />B0011111,<br />B0000000};<br /><br />const int _D[] = {B1111100,<br />B0100010,<br />B0100001,<br />B0100001,<br />B0100001,<br />B0100010,<br />B1111100,<br />B0000000};<br /><br />const int _E[] = {B1111111,<br />B1000000,<br />B1000000,<br />B1111100,<br />B1000000,<br />B1000000,<br />B1111111,<br />B0000000};<br /><br />const int _F[] = {B1111111,<br />B1000000,<br />B1000000,<br />B1111100,<br />B1000000,<br />B1000000,<br />B1000000,<br />B0000000};<br /><br />const int _G[] = {B0011111,<br />B0100000,<br />B1000000,<br />B1001111,<br />B1000001,<br />B0100001,<br />B0011111,<br />B0000000};<br /><br />const int _H[] = {B1000001,<br />B1000001,<br />B1000001,<br />B1111111,<br />B1000001,<br />B1000001,<br />B1000001,<br />B0000000};<br /><br />const int _I[] = {B1111111,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B1111111,<br />B0000000};<br /><br />const int _J[] = {B0001111,<br />B0000001,<br />B0000001,<br />B0000001,<br />B0000001,<br />B1000001,<br />B0111110,<br />B0000000};<br /><br />const int _K[] = {B1000011,<br />B1000100,<br />B1001000,<br />B1110000,<br />B1001000,<br />B1000100,<br />B1000011,<br />B0000000};<br /><br />const int _L[] = {B1000000,<br />B1000000,<br />B1000000,<br />B1000000,<br />B1000000,<br />B1000000,<br />B1111111,<br />B0000000};<br /><br />const int _M[] = {B1110110,<br />B1001001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B0000000};<br /><br />const int _N[] = {B1000001,<br />B1100001,<br />B1010001,<br />B1001001,<br />B1000101,<br />B1000011,<br />B1000001,<br />B0000000};<br /><br />const int _O[] = {B0011100,<br />B0100010,<br />B1000001,<br />B1001001,<br />B1000001,<br />B0100010,<br />B0011100,<br />B0000000};<br /><br />const int _P[] = {B1111110,<br />B0100001,<br />B0100001,<br />B0111110,<br />B0100000,<br />B0100000,<br />B0100000,<br />B0000000};<br /><br />const int _Q[] = {B0011100,<br />B0100010,<br />B1000001,<br />B1000001,<br />B1000101,<br />B0100010,<br />B0011101,<br />B0000000};<br /><br />const int _R[] = {B1111110,<br />B0100001,<br />B0100001,<br />B0101110,<br />B0100100,<br />B0100010,<br />B0100001,<br />B0000000};<br /><br />const int _S[] = {B0111111,<br />B1000000,<br />B1000000,<br />B0111110,<br />B0000001,<br />B0000001,<br />B1111110,<br />B0000000};<br /><br />const int _T[] = {B1111111,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0000000};<br /><br />const int _U[] = {B1000001,<br />B1000001,<br />B1000001,<br />B1000001,<br />B1000001,<br />B1000001,<br />B0111110,<br />B0000000};<br /><br />const int _V[] = {B1000001,<br />B1000001,<br />B1000001,<br />B1000001,<br />B0100010,<br />B0010100,<br />B0001000,<br />B0000000};<br /><br />const int _W[] = {B1000001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B1001001,<br />B0110110,<br />B0000000};<br /><br />const int _X[] = {B1000001,<br />B0100010,<br />B0010100,<br />B0001000,<br />B0010100,<br />B0100010,<br />B1000001,<br />B0000000};<br /><br />const int _Y[] = {B1000001,<br />B0100010,<br />B0010100,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0001000,<br />B0000000};<br /><br />const int _Z[] = {B1111111,<br />B0000010,<br />B0000100,<br />B0111110,<br />B0010000,<br />B0100000,<br />B1111111,<br />B0000000};<br /><br />const int _COL[] = {B0000000,<br />B0011000,<br />B0011000,<br />B0000000,<br />B0011000,<br />B0011000,<br />B0000000,<br />B0000000};<br /><br />const int _DASH[] = {B0000000,<br />B0000000,<br />B0000000,<br />B0111110,<br />B0000000,<br />B0000000,<br />B0000000,<br />B0000000};<br /><br />const int _BRA2[] = {B0010000,<br />B0001000,<br />B0000100,<br />B0000100,<br />B0001000,<br />B0010000,<br />B0000000,<br />B0000000};<br /><br />const int __[] = {B0000000,<br />B0000000,<br />B0000000,<br />B0000000,<br />B0000000,<br />B0000000,<br />B0000000,<br />B0000000};<br /><br />const int _FULL[] = {B1111111,<br />B1111111,<br />B1111111,<br />B1111111,<br />B1111111,<br />B1111111,<br />B1111111,<br />B0000000};<br /><br />const int _CHECK[] = {B1010101,<br />B0101010,<br />B1010101,<br />B0101010,<br />B1010101,<br />B0101010,<br />B1010101,<br />B0000000};<br /><br />const int _A3[] = {B0111110,<br />B0000001,<br />B0000001,<br />B0001111,<br />B0000001,<br />B1000001,<br />B0111110,<br />B0000000};<br /><br />const int _TEMP[] = {B0000011,<br />B0011111,<br />B0111111,<br />B1111110,<br />B1111111,<br />B0011111,<br />B0000011,<br />B0000000};<br /><br />const int _LINE[] = {B0000001,<br />B0000001,<br />B0000001,<br />B0000001,<br />B0000001,<br />B0000001,<br />B0000001,<br />B0000000};<br /><br />const int _SMILE[] = {B1100110,<br />B1100110,<br />B0000000,<br />B0011100,<br />B1000001,<br />B0100010,<br />B0011100,<br />B0000000};<br /><br /><br />const int _DOT[] = {B0000000,<br />B0000000,<br />B0000000,<br />B0000000,<br />B1100000,<br />B1100000,<br />B0000000,<br />B0000000};<br /><br />const int _COLDOT[] = {B0000000,<br />B0110000,<br />B0110000,<br />B0000000,<br />B0110011,<br />B0110011,<br />B0000000,<br />B0000000};<br /><br />//Load the bitmap charachters into an array (each charachters position corresponds to its previously defined index (ie _A (a's bitmap)<br />//is at index 0 and A = 0 so letters[A] will return the 'A' bitmap)<br />const int* letters[] = {_A,_B,_C,_D,_E,_F,_G,_H,_I,_J,_K,_L,_M,_N,_O,_P,_Q,_R,_S,_T,_U,_V,_W,_X,_Y,_Z,_COL,_DASH,_BRA2,__, _FULL, _CHECK, _A3, _TEMP, _LINE, _SMILE, _DOT, _COLDOT};<br /><br />//Setup runs once when power is applied<br /><br />// val : bit_2=caps_lock, bit_1=num_lock, bit_0=scroll_lock<br />void kbd_set_lights(byte val) {<br />kbd.write(0xED);<br />kbd.read(); // pull out the ack byte<br />kbd.write(val); // now send the data<br />}<br /><br />byte lookupCode() {<br />byte result = ps2Keyboard_CharBuffer;<br /><br />// Use a switch for the code to character conversion.<br />// This is fast and actually only uses 4 bytes per simple line<br />switch (result) {<br />case 0x1C: result = 'a'; break;<br />case 0x32: result = 'b'; break;<br />case 0x21: result = 'c'; break;<br />case 0x23: result = 'd'; break;<br />case 0x24: result = 'e'; break;<br />case 0x2B: result = 'f'; break;<br />case 0x34: result = 'g'; break;<br />case 0x33: result = 'h'; break;<br />case 0x43: result = 'i'; break;<br />case 0x3B: result = 'j'; break;<br />case 0x42: result = 'k'; break;<br />case 0x4B: result = 'l'; break;<br />case 0x3A: result = 'm'; break;<br />case 0x31: result = 'n'; break;<br />case 0x44: result = 'o'; break;<br />case 0x4D: result = 'p'; break;<br />case 0x15: result = 'q'; break;<br />case 0x2D: result = 'r'; break;<br />case 0x1B: result = 's'; break;<br />case 0x2C: result = 't'; break;<br />case 0x3C: result = 'u'; break;<br />case 0x2A: result = 'v'; break;<br />case 0x1D: result = 'w'; break;<br />case 0x22: result = 'x'; break;<br />case 0x35: result = 'y'; break;<br />case 0x1A: result = 'z'; break;<br />case 0x29: result = ' '; break;<br /><br /><br />// Reset the shift counter for unexpected values, to get back into sync<br />// This allows for hot plugging a keyboard in and out<br />default: delay(500); // but wait a bit in case part way through a shift<br />ps2Keyboard_shift = false;<br />ps2Keyboard_ctrl = false;<br />ps2Keyboard_alt = false;<br />ps2Keyboard_extend = false;<br />ps2Keyboard_release = false;<br />ps2Keyboard_caps_lock = false;<br />} // end switch(result)<br /><br />// done with the character<br />ps2Keyboard_CharBuffer = 0;<br />return(result);<br />}<br />int getChar(char lookupCode){<br />int returnValue = _;<br />switch(lookupCode){<br />case 'A': returnValue = A; break;<br />case 'a': returnValue = A; break;<br />case 'B': returnValue = B; break;<br />case 'b': returnValue = B; break;<br />case 'C': returnValue = C; break;<br />case 'c': returnValue = C; break;<br />case 'D': returnValue = D; break;<br />case 'd': returnValue = D; break;<br />case 'E': returnValue = E; break;<br />case 'e': returnValue = E; break;<br />case 'F': returnValue = F; break;<br />case 'f': returnValue = F; break;<br />case 'G': returnValue = G; break;<br />case 'g': returnValue = G; break;<br />case 'H': returnValue = H; break;<br />case 'h': returnValue = H; break;<br />case 'I': returnValue = I; break;<br />case 'i': returnValue = I; break;<br />case 'J': returnValue = J; break;<br />case 'j': returnValue = J; break;<br />case 'K': returnValue = K; break;<br />case 'k': returnValue = K; break;<br />case 'L': returnValue = L; break;<br />case 'l': returnValue = L; break;<br />case 'M': returnValue = M; break;<br />case 'm': returnValue = M; break;<br />case 'N': returnValue = N; break;<br />case 'n': returnValue = N; break;<br />case 'O': returnValue = O; break;<br />case 'o': returnValue = O; break;<br />case 'P': returnValue = P; break;<br />case 'p': returnValue = P; break;<br />case 'Q': returnValue = Q; break;<br />case 'q': returnValue = Q; break;<br />case 'R': returnValue = R; break;<br />case 'r': returnValue = R; break;<br />case 'S': returnValue = S; break;<br />case 's': returnValue = S; break;<br />case 'T': returnValue = T; break;<br />case 't': returnValue = T; break;<br />case 'U': returnValue = U; break;<br />case 'u': returnValue = U; break;<br />case 'V': returnValue = V; break;<br />case 'v': returnValue = V; break;<br />case 'W': returnValue = W; break;<br />case 'w': returnValue = W; break;<br />case 'X': returnValue = X; break;<br />case 'x': returnValue = X; break;<br />case 'Y': returnValue = Y; break;<br />case 'y': returnValue = Y; break;<br />case 'Z': returnValue = Z; break;<br />case 'z': returnValue = Z; break;<br />case ' ': returnValue = _; break;<br />case '3': returnValue = A3; break;<br />case '<': returnValue = TEMP; break; case '*': returnValue = FULL; break; case '': returnValue = LINE; break; case '_': returnValue = _; break; case ':': returnValue = COL; break; case '-': returnValue = DASH; break; case ')': returnValue = BRA2; break; case '%': returnValue = SMILE; break; case '.': returnValue = DOT; break; case '^': returnValue = COLDOT; break; } return returnValue; } void kbd_init() { char ack; kbd.write(0xff); // send reset code ack = kbd.read(); // byte, kbd does self test ack = kbd.read(); // another ack when self test is done } void setup() { Serial.begin(9600); kbd_init(); code = kbd.read(); for(int i = 0; i <8; code =" kbd.read();" ps2keyboard_release =" true;" ps2keyboard_extend =" false;" cmd_ack_byte_ok =" true;" ps2keyboard_extend =" true;" ps2keyboard_shift =" ps2Keyboard_release?" ps2keyboard_release =" false;" ps2keyboard_alt =" ps2Keyboard_release?" ps2keyboard_release =" false;" ps2keyboard_ctrl =" ps2Keyboard_release?" ps2keyboard_release =" false;" ps2keyboard_caps_lock =" ps2Keyboard_caps_lock?" ps2keyboard_release =" false;" ps2keyboard_release =" false;" ps2keyboard_charbuffer =" code;" i ="0;" currentchar =" getChar(requestString[index]);" nextchar =" getChar(requestString[index+1]);" row="0;" column="0;">> (8-offset) )); //loads the next charachter offset by offset pixels<br />}<br />}<br />offset++; //increment the offset by one row<br />if(offset==8){offset = 0; index++; if(index==sizeof(requestString)-2){index=0;}} //if offset is 8 load the next charachter pair for the next time through<br />}<br /><br />void showSprite(int speed2){<br />for(int iii = 0; iii < column =" 0;" i =" 0;" i =" 0;" i ="=" row =" 0;" bit =" (data[column]">> row) & 1;<br />if(bit == 1){<br />digitalWrite(rowA[row], HIGH); //if the bit in the data array is set turn the LED on<br />}<br /><br />}<br />delayMicroseconds(pauseDelay); //leave the column on for pauseDelay microseconds (too high a delay causes flicker)<br />}<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com1tag:blogger.com,1999:blog-4511835769708185792.post-83406996201258695922010-05-06T16:25:00.000-07:002010-05-06T16:26:53.882-07:00Task 53 - Fill the total eeprom with $AB's (171)<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDSZkz_xA3VBWYjKSa6H5JpBziKUglH9Y7-QQEMfLbAqFA2ig9kspBK6WnA3NHOcYFfSehYJCQ0FPaJSF3vHq1LQRIxR5xOVRVGmkkeTiflJzwaMkYaDAKgGnjJ25EVznOwGgxOTY0jg/s1600/untitled.bmp"><img style="cursor:pointer; cursor:hand;width: 320px; height: 272px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDSZkz_xA3VBWYjKSa6H5JpBziKUglH9Y7-QQEMfLbAqFA2ig9kspBK6WnA3NHOcYFfSehYJCQ0FPaJSF3vHq1LQRIxR5xOVRVGmkkeTiflJzwaMkYaDAKgGnjJ25EVznOwGgxOTY0jg/s320/untitled.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5468302570964677186" /></a><br /><br /><br />This program fills the EEPROM with Hex $AB or Decimal 171 and displays it on serial screen.<br /><br /><br />#include <EEPROM.h><br /><br />int a = 0;<br />int value;<br /><br />void setup()<br />{<br /> Serial.begin(9600);<br /> for (int i = 0; i < 512; i++)<br /> EEPROM.write(i, 171);<br /><br /> <br />}<br /><br />void loop()<br />{<br /> value = EEPROM.read(a);<br /><br /> Serial.print(a);<br /> Serial.print("\t");<br /> Serial.print(value);<br /> Serial.println();<br /><br /> a = a + 1;<br /><br /> if (a == 512)<br /> a = 0;<br /><br /> delay(500);<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-20269681016465606552010-05-06T16:21:00.000-07:002010-05-06T16:22:55.040-07:00Task 52 - Writting to EEPROM<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRAMjfHhtKXw3Foz8r-nzO5du1dCbc8t-2-IQnetGEu1OmensvULhtusbO3vDdN81xlrcnnKPkZjxH1iQlz8DeeSJU-ImrGheqdKUvWeUm95G5-RXUs3P9Yccmr3MCt0wBa6Z1T6TwcA/s1600/untitled.bmp"><img style="cursor:pointer; cursor:hand;width: 294px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRAMjfHhtKXw3Foz8r-nzO5du1dCbc8t-2-IQnetGEu1OmensvULhtusbO3vDdN81xlrcnnKPkZjxH1iQlz8DeeSJU-ImrGheqdKUvWeUm95G5-RXUs3P9Yccmr3MCt0wBa6Z1T6TwcA/s320/untitled.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5468301536287601794" /></a><br /><br /><br />The program writes $23(35) to address 01 and $2A(42) to address 02 and displays them to the screen.<br /><br />#include <EEPROM.h><br /><br />int a = 0;<br />int value;<br /><br />void setup()<br />{<br /> Serial.begin(9600);<br /> <br /> EEPROM.write(1, 35);<br /> EEPROM.write(2, 42);<br /> <br />}<br /><br />void loop()<br />{<br /> value = EEPROM.read(a);<br /><br /> Serial.print(a);<br /> Serial.print("\t");<br /> Serial.print(value);<br /> Serial.println();<br /><br /> a = a + 1;<br /><br /> if (a == 512)<br /> a = 0;<br /><br /> delay(500);<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-50666709307770337992010-05-06T15:59:00.000-07:002010-05-06T16:06:30.793-07:00Task 51 - EEPROM<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4uM7YOQ7J2yW4bl95cKYxQn_PRbU1pf8mB1xT1DczJQnUYviUOvuldzAyEFc7Fd6DS5isovL9D2d8MP2u_lZ5XS_XPelfFVEKIO2eMadm2sV41c6-giseIkE5Lm4OVmYYwermqPX-lw/s1600/untitled.bmp"><img style="cursor:pointer; cursor:hand;width: 275px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4uM7YOQ7J2yW4bl95cKYxQn_PRbU1pf8mB1xT1DczJQnUYviUOvuldzAyEFc7Fd6DS5isovL9D2d8MP2u_lZ5XS_XPelfFVEKIO2eMadm2sV41c6-giseIkE5Lm4OVmYYwermqPX-lw/s320/untitled.bmp" border="0" alt=""id="BLOGGER_PHOTO_ID_5468297297270874370" /></a><br />This program prints all values to the screen as FF (255) except the first byte in EEPROM which showed 69 (105).<br /><br />#include <EEPROM.h><br /><br />int a = 0;<br />int value;<br /><br />void setup()<br />{<br /> Serial.begin(9600);<br />}<br /><br />void loop()<br />{<br /> value = EEPROM.read(a);<br /><br /> Serial.print(a);<br /> Serial.print("\t");<br /> Serial.print(value);<br /> Serial.println();<br /><br /> a = a + 1;<br /><br /> if (a == 512)<br /> a = 0;<br /><br /> delay(10);<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-48573291146739159022010-04-29T16:53:00.000-07:002010-04-29T16:55:16.532-07:00Task 50 - How fast can you send a thousand 1/0 pulses and still count them accurately.The most accuarate count we could get is half a second otherwise it would not display it accuarately.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-32054149732628308752010-04-29T16:36:00.000-07:002010-04-29T16:53:08.535-07:00Task 49 - series of pulses, a 100, about 1ms long, to the other.I also did this task with BJ. On my arduino the code i used was:<br /><br />int reciever = 2;<br />int LED = 13;<br />int count = 0;<br /><br />void setup(){<br />pinMode(reciever,INPUT);<br />Serial.begin(9600);<br />}<br /><br />void loop(){<br />if (digitalRead(reciever)==1){<br />count++;<br />Serial.println(count);<br /><br />}<br />else{<br />}<br />delay(500);<br />} <br /><br />BJ's code was:<br /><br />void loop() <br />{<br />while (count < 1000){<br />digitalWrite(ledPin, HIGH); <br />delay(500); <br />digitalWrite(ledPin, LOW); <br />delay(500); <br />if(digitalRead(2)==1){<br />Serial.println('H');<br />}<br />count++;<br />}<br /><br />}<br /><br />This counts the incoming signal on my arduino when it is equal to 1 (high).Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-16618229632957221122010-04-29T16:23:00.000-07:002010-04-29T16:28:34.603-07:00Task 48 - receiving and sending a copy back for checking.I was working with BJ on this. On my arduino I had the following code:<br /><br />int reciever = 2;<br />int LED = 13;<br /><br />void setup(){<br />pinMode(reciever,INPUT);<br />Serial.begin(9600);<br />}<br /><br />void loop(){<br />//val = digitalRead(reciever);<br />if (digitalRead(reciever)==1){<br />Serial.println("H");<br />digitalWrite(LED,HIGH);<br />}<br />else{<br />digitalWrite(LED,LOW);<br />Serial.println("L");<br />}<br />delay(500);<br />} <br /><br />on BJ's arduino, he had the following code:<br /><br />void setup() { <br />// initialize the digital pin as an output:<br />pinMode(ledPin, OUTPUT); <br />Serial.begin(9600);<br />pinMode(2,INPUT);<br />}<br /><br />// the loop() method runs over and over again,<br />// as long as the Arduino has power<br /><br />void loop() <br />{<br />digitalWrite(ledPin, HIGH); <br />delay(1000); <br />if(digitalRead(2)==1){<br />Serial.println('H');<br />}<br />else{<br />Serial.println('L');<br />} <br />digitalWrite(ledPin, LOW); <br />delay(1000); <br />if(digitalRead(2)==1){<br />Serial.println('H');<br />}<br />else{<br />Serial.println('L');<br />} <br />} <br /><br />When blink goes on BJ's arduino it sends a signal to my arduino that outputs high or low to the screen, depending if it is a one or two. It then sends it back to BJ's arduino and does the same thing and outputs high or low to the screen.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-38830578653295042752010-04-26T03:15:00.000-07:002010-04-26T03:17:49.910-07:0047- reverse rolesFor this, we just swapped the roles of what the arduinos were doing. BJ had blink going, while I had his previous code on my Arduino. Then the same principles were applied as task 46.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-87437584562320864172010-04-26T03:04:00.000-07:002010-04-26T03:14:49.945-07:00Task 46 - Sending a signal from one Arduino to anotherI paired up with BJ to get one signal from one arduino to the other. BJ had the following code on his arduino:<br /><br />BJ Smid*/<br /><br />int reciever = 2;<br />int LED = 13;<br /><br />void setup(){<br />pinMode(reciever,INPUT);<br />Serial.begin(9600);<br />}<br /><br />void loop(){<br />//val = digitalRead(reciever);<br />if (digitalRead(reciever)==1){<br />Serial.println("H");<br />digitalWrite(LED,HIGH);<br />}<br />else{<br />digitalWrite(LED,LOW);<br />Serial.println("L");<br />}<br />delay(500);<br />} <br /><br /><br />I just had blink programmed on my arduino. This allowed my arduino to pass over a signal to BJ's arduino telling it whether or not my LED was blinking. If it was lit up, the arduino would send a signal telling BJ's arduino to light up an LED, otherwise it would send a signal to make sure it was off. BJ's arduino would also output to the screen whether it was high(lit up) or low(off).Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-57240509347618233642010-04-26T02:59:00.000-07:002010-04-26T03:03:32.130-07:00Task 45 - infrared transmitter sends pulses to the receiver.I have had a bit a trouble getting this to work outside of class, however I have been able to get this working in class using the blink exampler. I have the transmitter pluged into pin 13 and ground and that sends pulses to the reciever, which is in series with an led. These were also grounded and have 3v3 to power them. This then makes the led to blink on and off.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-54088671220265152352010-03-22T22:44:00.000-07:002010-03-23T02:58:36.965-07:00Task 43 - Project Websites<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-9uE97ih92xWiWi1jIhM3G65AXJrRr2gQipjYVEtPQpoyb9MdeQ4szslno1yHnT6p128E5F3hZNM04SKf0zCC4u86knzPzySu1DG3x0PUVkdoePflV2XsO3Pa_IHCgRYzZFDCclpSoQ/s1600-h/3.jpg"><img style="WIDTH: 320px; HEIGHT: 269px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5451764440215201330" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-9uE97ih92xWiWi1jIhM3G65AXJrRr2gQipjYVEtPQpoyb9MdeQ4szslno1yHnT6p128E5F3hZNM04SKf0zCC4u86knzPzySu1DG3x0PUVkdoePflV2XsO3Pa_IHCgRYzZFDCclpSoQ/s320/3.jpg" /></a><br /><a href="http://hacknmod.com/hack/top-40-arduino-projects-of-the-web">http://hacknmod.com/hack/top-40-arduino-projects-of-the-web</a><br /><br />This website has some great projects such as the gameboy.<br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwXOwChkqkz8QV9fKJ06Je4pQ4Ohxoc0jOgQevfGYdc8iCNn4TaiWh6PLFPnNGLS08FzoV7-G8GdOvyYHmYlGUe651dpq4SzRwztFO0pt1Pw0oKo5W-ummPm2kOrdmd1TRA19fwGBqrA/s1600-h/4.jpg"><img style="WIDTH: 307px; HEIGHT: 320px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5451764306415951266" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwXOwChkqkz8QV9fKJ06Je4pQ4Ohxoc0jOgQevfGYdc8iCNn4TaiWh6PLFPnNGLS08FzoV7-G8GdOvyYHmYlGUe651dpq4SzRwztFO0pt1Pw0oKo5W-ummPm2kOrdmd1TRA19fwGBqrA/s320/4.jpg" /></a><br /><a href="http://www.coolcircuit.com/gadgets/category/arduino/">http://www.coolcircuit.com/gadgets/category/arduino/</a><br /><br />This website also has some amazing products such as the wireless harp, I think it would be wicked to make something like that.<br /><br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz778ebsY4YxaQBwMWsAR_n3qanH6GkkmdNTThj5Ib2CUyWvxyJtsrHpeQFWqYKesK40snCqhIds33lkgHUXlWAJHMcTz02H969lWHa7gm7C2GTuDA1v39JDJe8MAsvidDt0F6TLMi_w/s1600-h/1.jpg"><img style="WIDTH: 320px; HEIGHT: 253px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5451764128254245026" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiz778ebsY4YxaQBwMWsAR_n3qanH6GkkmdNTThj5Ib2CUyWvxyJtsrHpeQFWqYKesK40snCqhIds33lkgHUXlWAJHMcTz02H969lWHa7gm7C2GTuDA1v39JDJe8MAsvidDt0F6TLMi_w/s320/1.jpg" /></a><br /><a href="http://missionduke.com/arduino-projects/">http://missionduke.com/arduino-projects/</a><br /><br />This website has a great project with Itunes and the Arduino, however I don't like apple therefore I don't use Itunes, however something could made similar with Windows Media Player.<br /><br /><br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQRY1bPhg0lY_W8z0GLMafPnlDdKAxv6pN28JYaFCm73hwPjzu5Q3lvD_saER92Wo55pQYt8p2X9puOh2ZF6aYigQHao5k4cFVD_Ns1lNhdtrAShbbU0l1ZWVdpin97A1GWw7TgflfUg/s1600-h/2.jpg"><img style="WIDTH: 320px; HEIGHT: 265px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5451763791717458226" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQRY1bPhg0lY_W8z0GLMafPnlDdKAxv6pN28JYaFCm73hwPjzu5Q3lvD_saER92Wo55pQYt8p2X9puOh2ZF6aYigQHao5k4cFVD_Ns1lNhdtrAShbbU0l1ZWVdpin97A1GWw7TgflfUg/s320/2.jpg" /></a><br /><a href="http://www.instructables.com/">http://www.instructables.com/</a><br /><br />This website has step by step guides into making some of the projects, however you have to register to access some things.<br /><br /><br /><p></p>Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-16559849021776480812010-03-22T17:35:00.000-07:002010-03-22T18:00:55.439-07:00Task 42 - Rules on YABB- No False Material<br />- No abusive , harassing behaviour<br />- No inaccurate material<br />- No hateful / threatening language towards other<br />- Treat everyone with respect<br />- Be politeAdam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-60971243606480514912010-03-22T17:24:00.000-07:002010-03-22T17:30:34.598-07:00Task 41 - Register to YABB<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbA8Nd16mMfjROCwcolcDZUpw-TRsKgkJZUSD8Cx6N2jUbTW0lL4dBBDz8sIKEQAMWElG86-CA5XdQs5IMfyJjobCSmz-rSu_wObajYLpG9JMXOd1hDH5pZ5W6rlVtoghoFdA2MpO8wA/s1600-h/2222.jpg"><img style="WIDTH: 320px; HEIGHT: 200px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5451619276836854114" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbA8Nd16mMfjROCwcolcDZUpw-TRsKgkJZUSD8Cx6N2jUbTW0lL4dBBDz8sIKEQAMWElG86-CA5XdQs5IMfyJjobCSmz-rSu_wObajYLpG9JMXOd1hDH5pZ5W6rlVtoghoFdA2MpO8wA/s320/2222.jpg" /></a><br /><div></div>Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-46492533680458778922010-03-18T15:34:00.000-07:002010-03-18T15:42:06.614-07:00Task 40 - Article from YABB<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKxyqmGzJh205_OPLglnuo0aQ44CumoRJBeianE1Tu0Zx7-U7bA2uCfL3uSe-WTHg7tokhs6n8vf1_0eWI3S5Vuw0j3hdqJvJ1c6dzo5-5WBvJK2J7p5X4Mr2aBKlz2qPBmaYj-NQShg/s1600-h/untitled.bmp"><img style="WIDTH: 320px; HEIGHT: 240px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5450106011767900146" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKxyqmGzJh205_OPLglnuo0aQ44CumoRJBeianE1Tu0Zx7-U7bA2uCfL3uSe-WTHg7tokhs6n8vf1_0eWI3S5Vuw0j3hdqJvJ1c6dzo5-5WBvJK2J7p5X4Mr2aBKlz2qPBmaYj-NQShg/s320/untitled.bmp" /></a><br /><br />This article was quite interesting. It is about a music LED visualizer which outputs different lights, when a song is being played. I was thinking about doing something similar for my major project, however it is a little confusing on how it is done. I will need to read up on it further.Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-30713529283492280412010-03-18T15:03:00.000-07:002010-03-18T15:08:05.128-07:00Task 39 - Same As Task 38 With Different Output//Program to output the value of your LDR whenever you press the button.<br /><br />int buttonPin = 2; // the number of the pushbutton pin<br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading; // the analog reading from the analog resistor divider<br />int buttonState = 0; // variable for reading the pushbutton status<br />int count = 1;<br /><br />void setup() { <br /> // initialize the pushbutton pin as an input:<br /> pinMode(buttonPin, INPUT); <br /> Serial.begin(9600); <br />}<br /><br />void loop(){<br /> <br /> photocellReading = analogRead(photocellPin); <br /> buttonState = digitalRead(buttonPin);<br /><br /> if (buttonState == HIGH) { <br /> Serial.print("Reading number ");<br /> Serial.print(count);<br /> Serial.print(": ");<br /> Serial.println(photocellReading); <br /> delay(500);<br /> count++;<br /> } <br /> else {<br /> buttonState == LOW;<br /> }<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0tag:blogger.com,1999:blog-4511835769708185792.post-80045869641365706742010-03-18T14:48:00.000-07:002010-03-18T15:02:05.755-07:00Task 38 - Program to output the value of your LDR whenever you press the button.//Program to output the value of your LDR whenever you press the button.<br /><br />int buttonPin = 2; // the number of the pushbutton pin<br />int photocellPin = 0; // the cell and 10K pulldown are connected to a0<br />int photocellReading; // the analog reading from the analog resistor divider<br />int buttonState = 0; // variable for reading the pushbutton status<br /><br />void setup() { <br /> // initialize the pushbutton pin as an input:<br /> pinMode(buttonPin, INPUT); <br /> Serial.begin(9600); <br />}<br /><br />void loop(){<br /> <br /> photocellReading = analogRead(photocellPin); <br /> buttonState = digitalRead(buttonPin);<br /><br /> if (buttonState == HIGH) { <br /> Serial.print("Analog reading = ");<br /> Serial.println(photocellReading); <br /> delay(500);<br /> } <br /> else {<br /> buttonState == LOW;<br /> }<br />}Adam Randallhttp://www.blogger.com/profile/07203058810019714518noreply@blogger.com0