<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: RowColumnScanning (sketch)</title>
		<link>http://forums.leaflabs.com/topic.php?id=1363</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:25:59 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=1363" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8281</link>
			<pubDate>Mon, 20 Feb 2012 12:44:22 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">8281@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;defuzo - just to be clear, I don't think that program works well. I was offering an explanation.&#60;br /&#62;
I understand how to light an 8x8 LED matrix. That program has nothing to do with &#34;16*4&#34;.&#60;/p&#62;
&#60;p&#62;In the code posted, an 'on' LED is on for less than 1/128th of a screen refresh, which can be improved a lot. When the program is written properly, an 'on' LED would be 'on' for close to 1/8th the screen refresh time.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>defuzo on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8278</link>
			<pubDate>Mon, 20 Feb 2012 10:46:52 +0000</pubDate>
			<dc:creator>defuzo</dc:creator>
			<guid isPermaLink="false">8278@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;dono refreshScreen(), its convoluted. 64 LED connected to 16 pins, 16*4.&#60;br /&#62;
Only if Col is low, and Row high, will the LED light.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8271</link>
			<pubDate>Sun, 19 Feb 2012 20:39:30 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">8271@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;A small comment ...&#60;/p&#62;
&#60;p&#62;I think this code in refreshScreen():&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// ...
        for (int thisCol = 0; thisCol &#38;lt; 8; thisCol++) {
            // get the state of the current pixel;
            int thisPixel = pixels[thisRow][thisCol];
            // when the row is HIGH and the col is LOW,
            // the LED where they meet turns on:
            digitalWrite(col[thisCol], thisPixel);
            // turn the pixel off:
            if (thisPixel == LOW) {
                digitalWrite(col[thisCol], HIGH);
            }
        }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;has almost the same effect as:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// ...
        for (int thisCol = 0; thisCol &#38;lt; 8; thisCol++) {
              digitalWrite(col[thisCol], HIGH);
        }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In the original, I guess an 'on' LED is on for less than 1/128th of the time it takes to refresh the screen, so it'll be quite dim. Is that true, or have I misunderstood something?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8270</link>
			<pubDate>Sun, 19 Feb 2012 16:39:27 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">8270@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;defuzo - I took the liberty of adding backtick characters around the code to preserve the indentation, and hopefully make it easier to read.&#60;/p&#62;
&#60;p&#62;What do you mean by 'good speed demo'? Are you comparing Maple with another board like an Arduino, or something else?&#60;/p&#62;
&#60;p&#62;I think an Arduino can run similar code, and give similar results because human 'persistence of vision' is so very slow by comparison. So I'm unclear what you are asking for.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>defuzo on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8269</link>
			<pubDate>Sun, 19 Feb 2012 15:11:28 +0000</pubDate>
			<dc:creator>defuzo</dc:creator>
			<guid isPermaLink="false">8269@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;(I made another mod, to grasp the speed of the cpu)&#60;/p&#62;
&#60;p&#62;short:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;void readSensors() {
  pixels[x][y] = HIGH;
  xf = 50 - map(analogRead(A0), 0, 1023, 0, 50) - 25;
  yf = map(analogRead(A1), 0, 1023, 0, 50) - 25;
  x = abs((x + xf) % 8 );
  y = abs((y + yf) % 8 );
  //  x = random(0, 8);
  //  y = random(0, 8);
  pixels[x][y] = LOW;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;It will produce something of various random pattern if x/y isnt a natural number.&#60;/p&#62;
&#60;p&#62;Anybody have any other good speed demo?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>defuzo on "RowColumnScanning (sketch)"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1363#post-8268</link>
			<pubDate>Sun, 19 Feb 2012 14:47:55 +0000</pubDate>
			<dc:creator>defuzo</dc:creator>
			<guid isPermaLink="false">8268@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hello.&#60;/p&#62;
&#60;p&#62;The included example &#34;RowColumnScanning&#34; didnt work, with same pins as the Arduino.&#60;br /&#62;
Pin 15-20 is 13-18, i thk :/&#60;/p&#62;
&#60;p&#62;Here is my working mod:&#60;br /&#62;
(function with same (real) pins on the Arduino)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// 2-dimensional array of row pin numbers:
const int row[8] = {
    2, 7, 20, 5, 13, 19, 12, 17 };

// 2-dimensional array of column pin numbers:
const int col[8] = {
    6, 11, 10, 3, 18, 4, 8, 9 };

// Analog input pins:
const int analogPin1 = 15;
const int analogPin2 = 16;

// 2-dimensional array of pixels:
int pixels[8][8];

// cursor position:
int x = 5;
int y = 5;

void setup() {
    // initialize the analog input pins as INPUT_ANALOG
    pinMode(analogPin1, INPUT_ANALOG);
    pinMode(analogPin2, INPUT_ANALOG);

    // initialize the I/O pins as outputs:

    // iterate over the pins:
    for (int thisPin = 0; thisPin &#38;lt; 8; thisPin++) {
        // initialize the output pins:
        pinMode(col[thisPin], OUTPUT);
        pinMode(row[thisPin], OUTPUT);
        // take the col pins (i.e. the cathodes) high to ensure that
        // the LEDS are off:
        digitalWrite(col[thisPin], HIGH);
    }

    // initialize the pixel matrix:
    for (int x = 0; x &#38;lt; 8; x++) {
        for (int y = 0; y &#38;lt; 8; y++) {
            pixels[x][y] = HIGH;
        }
    }
}

void loop() {
    // read input:
    readSensors();

    // draw the screen:
    refreshScreen();
}

void readSensors() {
    // turn off the last position:
    pixels[x][y] = HIGH;
    // read the sensors for X and Y values:
    x = 7 - map(analogRead(analogPin1), 0, 4095, 0, 7);
    y = map(analogRead(analogPin2), 0, 4095, 0, 7);
    // set the new pixel position low so that the LED will turn on
    // in the next screen refresh:
    pixels[x][y] = LOW;
}

void refreshScreen() {
    // iterate over the rows (anodes):
    for (int thisRow = 0; thisRow &#38;lt; 8; thisRow++) {
        // take the row pin (anode) high:
        digitalWrite(row[thisRow], HIGH);
        // iterate over the cols (cathodes):
        for (int thisCol = 0; thisCol &#38;lt; 8; thisCol++) {
            // get the state of the current pixel;
            int thisPixel = pixels[thisRow][thisCol];
            // when the row is HIGH and the col is LOW,
            // the LED where they meet turns on:
            digitalWrite(col[thisCol], thisPixel);
            // turn the pixel off:
            if (thisPixel == LOW) {
                digitalWrite(col[thisCol], HIGH);
            }
        }
        // take the row pin low to turn off the whole row:
        digitalWrite(row[thisRow], LOW);
    }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>

	</channel>
</rss>
