SlideShare a Scribd company logo
1 of 52
Download to read offline
Basic Programming Part III
Text-based video games arrays of char arrays
Computational poetry &
the cadavre exquis
random(), randomSeed()
Plotter art &
custom drawing machines
math functions
Glitch art
Choose your own adventure
Colossal Cave Adventure
Arrays of chars
Initialzing an
array of chars char message[] = {"hello"};
Initialzing an
array of an
array of chars
char message[][6] = {
{"hello"},
{"there"},
};
Length of
longest char
array in array
The compiler counts the elements and creates an array
of the appropriate size (length, starting at zero,
plus 1 for the null character '0' at the end)
Automatically
calculated (=2)
Arrays of chars
Printing an array of
chars in the array
(sizeof(message) / sizeof(message[0]));
Get number of arrays of
chars in the array
Serial.println(message[i]);
Index of array of
chars in array
total bytes in array / bytes of first element
= total number of elements
Love Letter Generator
Alan Turing
Love Letter Generator
https://nickm.com/memslam/love_letters.html
from random import choice
import textwrap
first = ['DARLING', 'DEAR', 'HONEY', 'JEWEL']
second = ['DUCK', 'LOVE', 'MOPPET', 'SWEETHEART']
adjectives = ['ADORABLE', 'AFFECTIONATE', 'AMOROUS', 'ANXIOUS', 'ARDENT', 'AVID', 'BREATHLESS', 'BURNING', 'COVETOUS', 'CRAVING', 'CURIOUS', 'DARLING', 'DEAR', 'DEVOTED', 'EAGER', 'EROTIC', 'FERVENT', 'FOND', 'IMPATIENT', 'KEEN', 'LITTLE',
'LOVEABLE', 'LOVESICK', 'LOVING', 'PASSIONATE', 'PRECIOUS', 'SWEET', 'SYMPATHETIC', 'TENDER', 'UNSATISFIED', 'WISTFUL']
nouns = ['ADORATION', 'AFFECTION', 'AMBITION', 'APPETITE', 'ARDOUR', 'CHARM', 'DESIRE', 'DEVOTION', 'EAGERNESS', 'ENCHANTMENT', 'ENTHUSIASM', 'FANCY', 'FELLOW FEELING', 'FERVOUR', 'FONDNESS', 'HEART', 'HUNGER', 'INFATUATION', 'LIKING', 'LONGING',
'LOVE', 'LUST', 'PASSION', 'RAPTURE', 'SYMPATHY', 'TENDERNESS', 'THIRST', 'WISH', 'YEARNING']
adverbs = ['AFFECTIONATELY', 'ANXIOUSLY', 'ARDENTLY', 'AVIDLY', 'BEAUTIFULLY', 'BREATHLESSLY', 'BURNINGLY', 'COVETOUSLY', 'CURIOUSLY', 'DEVOTEDLY', 'EAGERLY', 'FERVENTLY', 'FONDLY', 'IMPATIENTLY', 'KEENLY', 'LOVINGLY', 'PASSIONATELY', 'SEDUCTIVELY',
'TENDERLY', 'WINNINGLY', 'WISTFULLY']
verbs = ['ADORES', 'ATTRACTS', 'CARES FOR', 'CHERISHES', 'CLINGS TO', 'DESIRES','HOLDS DEAR', 'HOPES FOR', 'HUNGERS FOR', 'IS WEDDED TO', 'LIKES', 'LONGS FOR', 'LOVES', 'LUSTS AFTER', 'PANTS FOR', 'PINES FOR', 'PRIZES', 'SIGHS FOR', 'TEMPTS',
'THIRSTS FOR', 'TREASURES', 'WANTS', 'WISHES', 'WOOS', 'YEARNS FOR']
def maybe(words):
if choice([False, True]):
return ' ' + choice(words)
return ''
def longer():
return (' MY' + maybe(adjectives) + ' ' + choice(nouns) +
maybe(adverbs) + ' ' + choice(verbs) + ' YOUR' +
maybe(adjectives) + ' ' + choice(nouns) + '.')
def shorter():
return (' ' + choice(adjectives) + ' ' + choice(nouns) + '.')
text = ''
you_are = False
for i in range(0,5):
type = choice(['longer', 'shorter'])
if type == 'longer':
text = text + longer()
you_are = False
else:
if you_are:
text = text[:-1] + ': MY' + shorter()
you_are = False
else:
text = text + ' YOU ARE MY' + shorter()
you_are = True
print('')
print(choice(first) + ' ' + choice(second))
print('')
print(textwrap.fill(text, 80))
print('')
print(' YOURS ' + choice(adverbs))
print('')
print(' M.U.C.')
print('')
House of Dust
Alison Knowles
House of Dust
https://nickm.com/memslam/a_house_of_dust.html
from random import choice
material = ['SAND', 'DUST', 'LEAVES', 'PAPER', 'TIN', 'ROOTS', 'BRICK', 'STONE', 'DISCARDED CLOTHING', 'GLASS', 'STEEL',
'PLASTIC', 'MUD', 'BROKEN DISHES', 'WOOD', 'STRAW', 'WEEDS']
location = ['IN A GREEN, MOSSY TERRAIN', 'IN AN OVERPOPULATED AREA', 'BY THE SEA', 'BY AN ABANDONED LAKE', 'IN A DESERTED
FACTORY', 'IN DENSE WOODS', 'IN JAPAN', 'AMONG SMALL HILLS', 'IN SOUTHERN FRANCE', 'AMONG HIGH MOUNTAINS', 'ON AN ISLAND', 'IN A
COLD, WINDY CLIMATE', 'IN A PLACE WITH BOTH HEAVY RAIN AND BRIGHT SUN', 'IN A DESERTED AIRPORT', 'IN A HOT CLIMATE', 'INSIDE A
MOUNTAIN', 'ON THE SEA', 'IN MICHIGAN', 'IN HEAVY JUNGLE UNDERGROWTH', 'BY A RIVER', 'AMONG OTHER HOUSES', 'IN A DESERTED
CHURCH', 'IN A METROPOLIS', 'UNDERWATER']
light_source = ['CANDLES', 'ALL AVAILABLE LIGHTING', 'ELECTRICITY', 'NATURAL LIGHT']
inhabitants = ['PEOPLE WHO SLEEP VERY LITTLE', 'VEGETARIANS', 'HORSES AND BIRDS', 'PEOPLE SPEAKING MANY LANGUAGES WEARING LITTLE
OR NO CLOTHING', 'ALL RACES OF MEN REPRESENTED WEARING PREDOMINANTLY RED CLOTHING', 'CHILDREN AND OLD PEOPLE', 'VARIOUS BIRDS AND
FISH', 'LOVERS', 'PEOPLE WHO ENJOY EATING TOGETHER', 'PEOPLE WHO EAT A GREAT DEAL', 'COLLECTORS OF ALL TYPES', 'FRIENDS AND
ENEMIES', 'PEOPLE WHO SLEEP ALMOST ALL THE TIME', 'VERY TALL PEOPLE', 'AMERICAN INDIANS', 'LITTLE BOYS', 'PEOPLE FROM MANY WALKS
OF LIFE', 'NEGROS WEARING ALL COLORS', 'FRIENDS', 'FRENCH AND GERMAN SPEAKING PEOPLE', 'FISHERMEN AND FAMILIES', 'PEOPLE WHO LOVE
TO READ']
print('')
print('A HOUSE OF ' + choice(material))
print(' ' + choice(location))
print(' USING ' + choice(light_source))
print(' INHABITED BY ' + choice(inhabitants))
print('')
Cent mille milliards de poèmes
Raymond Queneau
Cadavre exquis
Jacques Prévert
Warsim
https://www.youtube.com/watch?v=IEJElbZuHAU&ab_channel=VegaVideoNetwork
random()
for (int i = 0; i < 5; i++)
// prints 5 pseudo-random numbers picked between 1-100
{
int x = random(100);
Serial.println(x);
}
randomSeed()
long randNumber;
void setup() {
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop() {
randNumber = random(100);
Serial.println(randNumber);
delay(50);
}
random string
char First [][30] = {
{ "You walk forward." },
{ "You hear a sound." },
{ "You turn to look behind you." },
{ "You open your backpack." },
};
void setup() {
Serial.begin (9600);
randomSeed(analogRead(0));
}
void loop() {
int randex = random(sizeof(First) / sizeof(First[0])); //random index in bounds
Serial.println(First[randex]);
}
Random terrain
char First [] = {"+ "};
void setup() {
Serial.begin (9600);
randomSeed(analogRead(0));
}
void loop() {
int length = sizeof(First) / sizeof(First[0]);
for(int i=0; i<50; i++)
{
Serial.println(" ");
for(int j=0; j<50; j++)
{
delay(10);
int randex = random(length-1);
Serial.print(First[randex]);
}
}
}
Probability terrain
char water [] = " "; //water = 0
char land [] = "+"; //land = 1
int waterChance = 50; //water = 0
int tile;
int prevTile = 0;
void setup() {
Serial.begin (9600);
randomSeed(analogRead(0));
}
void loop() {
for(int i=0; i<50; i++)
{
Serial.println();
for(int j=0; j<50; j++){
delay(10);
if (prevTile == 0){
waterChance += 10;
}
else if (prevTile == 1){
waterChance -= 10;
}
if (waterChance > 90){
waterChance = 80;
}
if (waterChance < 10){
waterChance = 20;
}
tile = random(100);
if (tile < waterChance){
Serial.print(water);
prevTile = 0;
}
else if (tile >= waterChance){
Serial.print(land);
prevTile = 1;
}
}
}
}
2D Glitch art
https://github.com/snorpey/glitch-canvas
https://www.glitchet.com/
resources
2D Glitch art
2D Glitch art
https://www.slideshare.net/r00s/rosa-menkman-a-vernacular-of-file-formats-4923967
2D Glitch art
iteration: changes how many times the main loop
runs. This will impact how many bytes are
rewritten in the image data portion of the
image (smaller the iteration, the more loops
and the more bytes transformed).
seed: changes how many bytes are skipped over
each time the loop runs as it moves from the
top to the bottom of the pixel data. (larger
the parameter, fewer bytes overwritten because
more bytes skipped over).
amount: the value of the new byte which is
overwritten each time through the loop. (larger
the value, larger the byte value the byte is
replaced with).
https://github.com/snorpey/glitch-canvas
2D Glitch art
Pixel sorting - Kim Asendorf
https://www.processing.org/tutorials/pixels/
2D Glitch art
https://github.com/snorpey/glitch-canvas
3D Glitch art
https://github.com/snorpey/glitch-canvas
3D Glitch art
https://github.com/snorpey/glitch-canvas
3D Glitch art
https://github.com/snorpey/glitch-canvas
3D Glitch art
https://github.com/snorpey/glitch-canvas
3D Glitch art
http://www.srcxor.org/blog/3d-glitching/
Mark Klink
3D Glitch art
http://www.srcxor.org/blog/3d-glitching/
Mark Klink
Wall Drawings Instructions
Sol Lewitt
Plotter Drawings
Manfred Mohr
Plotter Drawings
Vera Molnár
Plotter Drawings
Georg Nees
Arduino controlled
XY plotters
Processing
C++ like Arduino
For 2D visualizations
https://www.processing.org/tutorials/pixels/
Plotter Drawings Code
http://recodeproject.com/
Chris Allick
...
void drawRects() {
for( int i = 0; i < 400; i++ ) {
RoundedRect(
random(-10,width),
random(-10,height),
random( 5, 40),
random(5,40), 5, 5 );
}
}
...
http://recodeproject.com/translation/chris-allick-direct-random-squares-charles-csuri
Plotter Drawings Code
http://recodeproject.com/
Aaron Marcus
...
//generate random seed values for location and size
float randLoc = random(-gridSize/2,gridSize/2);
float randLoc2 = random(-gridSize/2,gridSize/2);
float randLoc3 = random(-gridSize/2,gridSize/2);
float randLoc4 = random(-gridSize/2,gridSize/2);
float randLoc5 = random(-gridSize/2,gridSize/2);
float randLoc6 = random(-gridSize/2,gridSize/2);
float randLoc7 = random(-gridSize/2,gridSize/2);
float randLoc8 = random(-gridSize/2,gridSize/2);
float sqSize = random(0, (gridSize-10)/2);
...
//draw squares
translate(x+randLoc3, y+randLoc4);
rotate(random(TWO_PI));
rect(0, 0, sqSize, sqSize);
...
http://recodeproject.com/artwork/v3n2untitled-2-marcus
Plotter Drawings Code
http://recodeproject.com/
Sermad Buni
...
if(canvasheight % 2 == 0) {
iw = canvaswidth/2 - Math.abs(i - canvaswidth/2);
} else {
iw = canvaswidth/2 - 0.5 - Math.abs(i - canvaswidth/2 - 0.5);
}
if(canvasheight % 2 == 0) {
jh = canvasheight/2 - 0.5 - Math.abs(j - canvasheight/2 + 0.5);
} else {
jh = canvasheight/2 - Math.abs(j - canvasheight/2);
}
// check if we are not drawing the outer edges
if( jh != 0 || iw != 0) {
// rotate the square
rotate( radians(iw * iw * jh * jh * random(-randomness,randomness)) );
...
http://recodeproject.com/translation/sermad-buni-direct-boxes-i-william-kolomyjec
Plotter Drawings Code
http://recodeproject.com/
// do the strokes in a random different order each time
Collections.shuffle(strokes);
for (int i = 0; i < distFromMiddle; i++) {
drawSegment( strokes.get(i), boxSize, boxSize);
}
…
void drawSegment(int i, int w, int h) {
switch(i) {
case 0:
line(0, 0, w, h);
break;
case 1:
line(w, 0, 0, h);
break;
case 2:
line(0, h/2, w, h/2);
break;
case 3:
line(0, h/2, w/2, 0);
break;
case 4:
line(w/2, 0, w, h/2);
break;
…
Greg Borenstein
http://recodeproject.com/translation/greg-borenstein-direct-structure-square-series-inwards-roger-coqart
Plotter Drawings Code
http://recodeproject.com/
Vera Molnar
http://recodeproject.com/translation/quin-kennedy-direct-unimaginable-images-vera-molnar
...
//for each grid cell...
for(int i = 0, gi = gutterSize; i < numTiles; i++, gi +=
gutterSize+tileSize){
for(int j = 0, gj = gutterSize; j < numTiles; j++, gj +=
gutterSize+tileSize){
drawTrapezium(gi+tileSize/2, gj+tileSize/2);
}
}
}
void drawTrapezium(float xCenter, float yCenter){
float topScale = random(-2, 2);
float bottomScale = random(-2, 2);
float halfTile = tileSize/2.;
quad(xCenter - tileSize/2 + random(-tileSize, tileSize),
yCenter - halfTile,
xCenter + tileSize/2 + random(-tileSize, tileSize),
yCenter - halfTile,
xCenter + tileSize/2 + random(-tileSize, tileSize),
yCenter + halfTile,
xCenter - tileSize/2 + random(-tileSize, tileSize),
yCenter + halfTile);
}
...
Math functions
float x,y;
double z;
z = pow(x, y);//(base, exp)
z = sq(x);
z = sqrt(x);
z = cos(x); // in radians
z = sin(x); // in radians
z = tan(x); // in radians
Float is a datatype for:
A number that has a decimal point.
Can store: 3.4028235E+38 to -3.4028235E+38.
6-7 decimal digits of precision (total
number of digits, not the number to the
right of the decimal point.)
Unlike other platforms, where you can get
more precision by using a double (e.g. up
to 15 digits), on the Arduino, double is
the same size as float.
One radian is 180/ degrees or just under
π
57.3°
Curve Drawing Machines
Curve Drawing Machines
Curve Drawing Machines
Eske Rex
Curve Drawing Machines
C = constants for positioning the
circles
, = speeds of the circles
α β
= offset in starting position
Φ
r1, r2 = radii of the circles
L1, L2 = lengths of the arms
(x1, y1), (x2, y2) = coordinates of
the "pivots" where the arms attach to
the circles
d = length between the pivots
h = altitude of the triangle formed
with the arms and d
a = length between the first pivot
and the point where h meets d
Drawing Machines
CW CCW
Drawing Machines
R = 1 R = 2
Drawing Machines
Drawing Machines
L1
L2
Drawing Machines
Drawing Machines
Speed = 1rpm Speed = 2rpm
Drawing Machines
Speed = 1/time Speed = constant

More Related Content

What's hot

[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon runMaja Kraljič
 
Google Go For Ruby Hackers
Google Go For Ruby HackersGoogle Go For Ruby Hackers
Google Go For Ruby HackersEleanor McHugh
 
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018Codemotion
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอมAreeya Onnom
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperosfameron
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosEdgar Suarez
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processingstefk00
 

What's hot (10)

[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
 
Google Go For Ruby Hackers
Google Go For Ruby HackersGoogle Go For Ruby Hackers
Google Go For Ruby Hackers
 
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
Meetup di Gruppo Game Jam Roma - Giorgio Pomettini - Codemotion Rome 2018
 
Rust & Gamedev
Rust & GamedevRust & Gamedev
Rust & Gamedev
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
รายงานคอม
รายงานคอมรายงานคอม
รายงานคอม
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
Desarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutosDesarrollando aplicaciones web en minutos
Desarrollando aplicaciones web en minutos
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processing
 

Similar to Arduino creative coding class part iii

A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009Jordan Baker
 
Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutesSidharth Nadhan
 
Python basic
Python basic Python basic
Python basic sewoo lee
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python TricksBryan Helmig
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Paige Bailey
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojureJuio Barros
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_AltHiroshi Ono
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon RunMaja Kraljič
 
2013 lecture-02-syntax shortnewcut
2013 lecture-02-syntax shortnewcut2013 lecture-02-syntax shortnewcut
2013 lecture-02-syntax shortnewcutPharo
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NYCrystal Language
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!priort
 

Similar to Arduino creative coding class part iii (20)

A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009
 
Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutes
 
Python basic
Python basic Python basic
Python basic
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
Intro to programming games with clojure
Intro to programming games with clojureIntro to programming games with clojure
Intro to programming games with clojure
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
PyCon2009_AI_Alt
PyCon2009_AI_AltPyCon2009_AI_Alt
PyCon2009_AI_Alt
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
P3 2018 python_regexes
P3 2018 python_regexesP3 2018 python_regexes
P3 2018 python_regexes
 
[SI] Ada Lovelace Day 2014 - Tampon Run
[SI] Ada Lovelace Day 2014  - Tampon Run[SI] Ada Lovelace Day 2014  - Tampon Run
[SI] Ada Lovelace Day 2014 - Tampon Run
 
2013 lecture-02-syntax shortnewcut
2013 lecture-02-syntax shortnewcut2013 lecture-02-syntax shortnewcut
2013 lecture-02-syntax shortnewcut
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Crystal presentation in NY
Crystal presentation in NYCrystal presentation in NY
Crystal presentation in NY
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!Beginning Haskell, Dive In, Its Not That Scary!
Beginning Haskell, Dive In, Its Not That Scary!
 

More from Jonah Marrs

Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2Jonah Marrs
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part iiJonah Marrs
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding classJonah Marrs
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshopJonah Marrs
 
Shop bot training
Shop bot trainingShop bot training
Shop bot trainingJonah Marrs
 
Microcontroller primer
Microcontroller primerMicrocontroller primer
Microcontroller primerJonah Marrs
 
Eagle pcb tutorial
Eagle pcb tutorialEagle pcb tutorial
Eagle pcb tutorialJonah Marrs
 

More from Jonah Marrs (9)

Sensors class
Sensors classSensors class
Sensors class
 
Etapes fab-venti-v2
Etapes fab-venti-v2Etapes fab-venti-v2
Etapes fab-venti-v2
 
Arduino coding class part ii
Arduino coding class part iiArduino coding class part ii
Arduino coding class part ii
 
Arduino coding class
Arduino coding classArduino coding class
Arduino coding class
 
Assembly class
Assembly classAssembly class
Assembly class
 
Arduino workshop
Arduino workshopArduino workshop
Arduino workshop
 
Shop bot training
Shop bot trainingShop bot training
Shop bot training
 
Microcontroller primer
Microcontroller primerMicrocontroller primer
Microcontroller primer
 
Eagle pcb tutorial
Eagle pcb tutorialEagle pcb tutorial
Eagle pcb tutorial
 

Recently uploaded

VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCR
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCRCall In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCR
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCRdollysharma2066
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCRdollysharma2066
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfShivakumar Viswanathan
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Design principles on typography in design
Design principles on typography in designDesign principles on typography in design
Design principles on typography in designnooreen17
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一F La
 
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...Amil baba
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024CristobalHeraud
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVAAnastasiya Kudinova
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一diploma 1
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degreeyuu sss
 
Call Girls Meghani Nagar 7397865700 Independent Call Girls
Call Girls Meghani Nagar 7397865700  Independent Call GirlsCall Girls Meghani Nagar 7397865700  Independent Call Girls
Call Girls Meghani Nagar 7397865700 Independent Call Girlsssuser7cb4ff
 
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改yuu sss
 

Recently uploaded (20)

VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCR
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCRCall In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCR
Call In girls Bhikaji Cama Place 🔝 ⇛8377877756 FULL Enjoy Delhi NCR
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdf
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Harsh Vihar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Design principles on typography in design
Design principles on typography in designDesign principles on typography in design
Design principles on typography in design
 
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
办理(宾州州立毕业证书)美国宾夕法尼亚州立大学毕业证成绩单原版一比一
 
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
NO1 Famous Amil Baba In Karachi Kala Jadu In Karachi Amil baba In Karachi Add...
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
PORTFOLIO DE ARQUITECTURA CRISTOBAL HERAUD 2024
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
 
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
Call Girls In Safdarjung Enclave 24/7✡️9711147426✡️ Escorts Service
 
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
办理(USYD毕业证书)澳洲悉尼大学毕业证成绩单原版一比一
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
 
Call Girls Meghani Nagar 7397865700 Independent Call Girls
Call Girls Meghani Nagar 7397865700  Independent Call GirlsCall Girls Meghani Nagar 7397865700  Independent Call Girls
Call Girls Meghani Nagar 7397865700 Independent Call Girls
 
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
1比1办理美国北卡罗莱纳州立大学毕业证成绩单pdf电子版制作修改
 
Call Girls in Pratap Nagar, 9953056974 Escort Service
Call Girls in Pratap Nagar,  9953056974 Escort ServiceCall Girls in Pratap Nagar,  9953056974 Escort Service
Call Girls in Pratap Nagar, 9953056974 Escort Service
 

Arduino creative coding class part iii

  • 1. Basic Programming Part III Text-based video games arrays of char arrays Computational poetry & the cadavre exquis random(), randomSeed() Plotter art & custom drawing machines math functions Glitch art
  • 2. Choose your own adventure
  • 4. Arrays of chars Initialzing an array of chars char message[] = {"hello"}; Initialzing an array of an array of chars char message[][6] = { {"hello"}, {"there"}, }; Length of longest char array in array The compiler counts the elements and creates an array of the appropriate size (length, starting at zero, plus 1 for the null character '0' at the end) Automatically calculated (=2)
  • 5. Arrays of chars Printing an array of chars in the array (sizeof(message) / sizeof(message[0])); Get number of arrays of chars in the array Serial.println(message[i]); Index of array of chars in array total bytes in array / bytes of first element = total number of elements
  • 7. Love Letter Generator https://nickm.com/memslam/love_letters.html from random import choice import textwrap first = ['DARLING', 'DEAR', 'HONEY', 'JEWEL'] second = ['DUCK', 'LOVE', 'MOPPET', 'SWEETHEART'] adjectives = ['ADORABLE', 'AFFECTIONATE', 'AMOROUS', 'ANXIOUS', 'ARDENT', 'AVID', 'BREATHLESS', 'BURNING', 'COVETOUS', 'CRAVING', 'CURIOUS', 'DARLING', 'DEAR', 'DEVOTED', 'EAGER', 'EROTIC', 'FERVENT', 'FOND', 'IMPATIENT', 'KEEN', 'LITTLE', 'LOVEABLE', 'LOVESICK', 'LOVING', 'PASSIONATE', 'PRECIOUS', 'SWEET', 'SYMPATHETIC', 'TENDER', 'UNSATISFIED', 'WISTFUL'] nouns = ['ADORATION', 'AFFECTION', 'AMBITION', 'APPETITE', 'ARDOUR', 'CHARM', 'DESIRE', 'DEVOTION', 'EAGERNESS', 'ENCHANTMENT', 'ENTHUSIASM', 'FANCY', 'FELLOW FEELING', 'FERVOUR', 'FONDNESS', 'HEART', 'HUNGER', 'INFATUATION', 'LIKING', 'LONGING', 'LOVE', 'LUST', 'PASSION', 'RAPTURE', 'SYMPATHY', 'TENDERNESS', 'THIRST', 'WISH', 'YEARNING'] adverbs = ['AFFECTIONATELY', 'ANXIOUSLY', 'ARDENTLY', 'AVIDLY', 'BEAUTIFULLY', 'BREATHLESSLY', 'BURNINGLY', 'COVETOUSLY', 'CURIOUSLY', 'DEVOTEDLY', 'EAGERLY', 'FERVENTLY', 'FONDLY', 'IMPATIENTLY', 'KEENLY', 'LOVINGLY', 'PASSIONATELY', 'SEDUCTIVELY', 'TENDERLY', 'WINNINGLY', 'WISTFULLY'] verbs = ['ADORES', 'ATTRACTS', 'CARES FOR', 'CHERISHES', 'CLINGS TO', 'DESIRES','HOLDS DEAR', 'HOPES FOR', 'HUNGERS FOR', 'IS WEDDED TO', 'LIKES', 'LONGS FOR', 'LOVES', 'LUSTS AFTER', 'PANTS FOR', 'PINES FOR', 'PRIZES', 'SIGHS FOR', 'TEMPTS', 'THIRSTS FOR', 'TREASURES', 'WANTS', 'WISHES', 'WOOS', 'YEARNS FOR'] def maybe(words): if choice([False, True]): return ' ' + choice(words) return '' def longer(): return (' MY' + maybe(adjectives) + ' ' + choice(nouns) + maybe(adverbs) + ' ' + choice(verbs) + ' YOUR' + maybe(adjectives) + ' ' + choice(nouns) + '.') def shorter(): return (' ' + choice(adjectives) + ' ' + choice(nouns) + '.') text = '' you_are = False for i in range(0,5): type = choice(['longer', 'shorter']) if type == 'longer': text = text + longer() you_are = False else: if you_are: text = text[:-1] + ': MY' + shorter() you_are = False else: text = text + ' YOU ARE MY' + shorter() you_are = True print('') print(choice(first) + ' ' + choice(second)) print('') print(textwrap.fill(text, 80)) print('') print(' YOURS ' + choice(adverbs)) print('') print(' M.U.C.') print('')
  • 9. House of Dust https://nickm.com/memslam/a_house_of_dust.html from random import choice material = ['SAND', 'DUST', 'LEAVES', 'PAPER', 'TIN', 'ROOTS', 'BRICK', 'STONE', 'DISCARDED CLOTHING', 'GLASS', 'STEEL', 'PLASTIC', 'MUD', 'BROKEN DISHES', 'WOOD', 'STRAW', 'WEEDS'] location = ['IN A GREEN, MOSSY TERRAIN', 'IN AN OVERPOPULATED AREA', 'BY THE SEA', 'BY AN ABANDONED LAKE', 'IN A DESERTED FACTORY', 'IN DENSE WOODS', 'IN JAPAN', 'AMONG SMALL HILLS', 'IN SOUTHERN FRANCE', 'AMONG HIGH MOUNTAINS', 'ON AN ISLAND', 'IN A COLD, WINDY CLIMATE', 'IN A PLACE WITH BOTH HEAVY RAIN AND BRIGHT SUN', 'IN A DESERTED AIRPORT', 'IN A HOT CLIMATE', 'INSIDE A MOUNTAIN', 'ON THE SEA', 'IN MICHIGAN', 'IN HEAVY JUNGLE UNDERGROWTH', 'BY A RIVER', 'AMONG OTHER HOUSES', 'IN A DESERTED CHURCH', 'IN A METROPOLIS', 'UNDERWATER'] light_source = ['CANDLES', 'ALL AVAILABLE LIGHTING', 'ELECTRICITY', 'NATURAL LIGHT'] inhabitants = ['PEOPLE WHO SLEEP VERY LITTLE', 'VEGETARIANS', 'HORSES AND BIRDS', 'PEOPLE SPEAKING MANY LANGUAGES WEARING LITTLE OR NO CLOTHING', 'ALL RACES OF MEN REPRESENTED WEARING PREDOMINANTLY RED CLOTHING', 'CHILDREN AND OLD PEOPLE', 'VARIOUS BIRDS AND FISH', 'LOVERS', 'PEOPLE WHO ENJOY EATING TOGETHER', 'PEOPLE WHO EAT A GREAT DEAL', 'COLLECTORS OF ALL TYPES', 'FRIENDS AND ENEMIES', 'PEOPLE WHO SLEEP ALMOST ALL THE TIME', 'VERY TALL PEOPLE', 'AMERICAN INDIANS', 'LITTLE BOYS', 'PEOPLE FROM MANY WALKS OF LIFE', 'NEGROS WEARING ALL COLORS', 'FRIENDS', 'FRENCH AND GERMAN SPEAKING PEOPLE', 'FISHERMEN AND FAMILIES', 'PEOPLE WHO LOVE TO READ'] print('') print('A HOUSE OF ' + choice(material)) print(' ' + choice(location)) print(' USING ' + choice(light_source)) print(' INHABITED BY ' + choice(inhabitants)) print('')
  • 10. Cent mille milliards de poèmes Raymond Queneau
  • 13. random() for (int i = 0; i < 5; i++) // prints 5 pseudo-random numbers picked between 1-100 { int x = random(100); Serial.println(x); }
  • 14. randomSeed() long randNumber; void setup() { Serial.begin(9600); randomSeed(analogRead(0)); } void loop() { randNumber = random(100); Serial.println(randNumber); delay(50); }
  • 15. random string char First [][30] = { { "You walk forward." }, { "You hear a sound." }, { "You turn to look behind you." }, { "You open your backpack." }, }; void setup() { Serial.begin (9600); randomSeed(analogRead(0)); } void loop() { int randex = random(sizeof(First) / sizeof(First[0])); //random index in bounds Serial.println(First[randex]); }
  • 16. Random terrain char First [] = {"+ "}; void setup() { Serial.begin (9600); randomSeed(analogRead(0)); } void loop() { int length = sizeof(First) / sizeof(First[0]); for(int i=0; i<50; i++) { Serial.println(" "); for(int j=0; j<50; j++) { delay(10); int randex = random(length-1); Serial.print(First[randex]); } } }
  • 17. Probability terrain char water [] = " "; //water = 0 char land [] = "+"; //land = 1 int waterChance = 50; //water = 0 int tile; int prevTile = 0; void setup() { Serial.begin (9600); randomSeed(analogRead(0)); } void loop() { for(int i=0; i<50; i++) { Serial.println(); for(int j=0; j<50; j++){ delay(10); if (prevTile == 0){ waterChance += 10; } else if (prevTile == 1){ waterChance -= 10; } if (waterChance > 90){ waterChance = 80; } if (waterChance < 10){ waterChance = 20; } tile = random(100); if (tile < waterChance){ Serial.print(water); prevTile = 0; } else if (tile >= waterChance){ Serial.print(land); prevTile = 1; } } } }
  • 21. 2D Glitch art iteration: changes how many times the main loop runs. This will impact how many bytes are rewritten in the image data portion of the image (smaller the iteration, the more loops and the more bytes transformed). seed: changes how many bytes are skipped over each time the loop runs as it moves from the top to the bottom of the pixel data. (larger the parameter, fewer bytes overwritten because more bytes skipped over). amount: the value of the new byte which is overwritten each time through the loop. (larger the value, larger the byte value the byte is replaced with). https://github.com/snorpey/glitch-canvas
  • 22. 2D Glitch art Pixel sorting - Kim Asendorf https://www.processing.org/tutorials/pixels/
  • 35. Processing C++ like Arduino For 2D visualizations https://www.processing.org/tutorials/pixels/
  • 36. Plotter Drawings Code http://recodeproject.com/ Chris Allick ... void drawRects() { for( int i = 0; i < 400; i++ ) { RoundedRect( random(-10,width), random(-10,height), random( 5, 40), random(5,40), 5, 5 ); } } ... http://recodeproject.com/translation/chris-allick-direct-random-squares-charles-csuri
  • 37. Plotter Drawings Code http://recodeproject.com/ Aaron Marcus ... //generate random seed values for location and size float randLoc = random(-gridSize/2,gridSize/2); float randLoc2 = random(-gridSize/2,gridSize/2); float randLoc3 = random(-gridSize/2,gridSize/2); float randLoc4 = random(-gridSize/2,gridSize/2); float randLoc5 = random(-gridSize/2,gridSize/2); float randLoc6 = random(-gridSize/2,gridSize/2); float randLoc7 = random(-gridSize/2,gridSize/2); float randLoc8 = random(-gridSize/2,gridSize/2); float sqSize = random(0, (gridSize-10)/2); ... //draw squares translate(x+randLoc3, y+randLoc4); rotate(random(TWO_PI)); rect(0, 0, sqSize, sqSize); ... http://recodeproject.com/artwork/v3n2untitled-2-marcus
  • 38. Plotter Drawings Code http://recodeproject.com/ Sermad Buni ... if(canvasheight % 2 == 0) { iw = canvaswidth/2 - Math.abs(i - canvaswidth/2); } else { iw = canvaswidth/2 - 0.5 - Math.abs(i - canvaswidth/2 - 0.5); } if(canvasheight % 2 == 0) { jh = canvasheight/2 - 0.5 - Math.abs(j - canvasheight/2 + 0.5); } else { jh = canvasheight/2 - Math.abs(j - canvasheight/2); } // check if we are not drawing the outer edges if( jh != 0 || iw != 0) { // rotate the square rotate( radians(iw * iw * jh * jh * random(-randomness,randomness)) ); ... http://recodeproject.com/translation/sermad-buni-direct-boxes-i-william-kolomyjec
  • 39. Plotter Drawings Code http://recodeproject.com/ // do the strokes in a random different order each time Collections.shuffle(strokes); for (int i = 0; i < distFromMiddle; i++) { drawSegment( strokes.get(i), boxSize, boxSize); } … void drawSegment(int i, int w, int h) { switch(i) { case 0: line(0, 0, w, h); break; case 1: line(w, 0, 0, h); break; case 2: line(0, h/2, w, h/2); break; case 3: line(0, h/2, w/2, 0); break; case 4: line(w/2, 0, w, h/2); break; … Greg Borenstein http://recodeproject.com/translation/greg-borenstein-direct-structure-square-series-inwards-roger-coqart
  • 40. Plotter Drawings Code http://recodeproject.com/ Vera Molnar http://recodeproject.com/translation/quin-kennedy-direct-unimaginable-images-vera-molnar ... //for each grid cell... for(int i = 0, gi = gutterSize; i < numTiles; i++, gi += gutterSize+tileSize){ for(int j = 0, gj = gutterSize; j < numTiles; j++, gj += gutterSize+tileSize){ drawTrapezium(gi+tileSize/2, gj+tileSize/2); } } } void drawTrapezium(float xCenter, float yCenter){ float topScale = random(-2, 2); float bottomScale = random(-2, 2); float halfTile = tileSize/2.; quad(xCenter - tileSize/2 + random(-tileSize, tileSize), yCenter - halfTile, xCenter + tileSize/2 + random(-tileSize, tileSize), yCenter - halfTile, xCenter + tileSize/2 + random(-tileSize, tileSize), yCenter + halfTile, xCenter - tileSize/2 + random(-tileSize, tileSize), yCenter + halfTile); } ...
  • 41. Math functions float x,y; double z; z = pow(x, y);//(base, exp) z = sq(x); z = sqrt(x); z = cos(x); // in radians z = sin(x); // in radians z = tan(x); // in radians Float is a datatype for: A number that has a decimal point. Can store: 3.4028235E+38 to -3.4028235E+38. 6-7 decimal digits of precision (total number of digits, not the number to the right of the decimal point.) Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float. One radian is 180/ degrees or just under π 57.3°
  • 45. Curve Drawing Machines C = constants for positioning the circles , = speeds of the circles α β = offset in starting position Φ r1, r2 = radii of the circles L1, L2 = lengths of the arms (x1, y1), (x2, y2) = coordinates of the "pivots" where the arms attach to the circles d = length between the pivots h = altitude of the triangle formed with the arms and d a = length between the first pivot and the point where h meets d
  • 51. Drawing Machines Speed = 1rpm Speed = 2rpm
  • 52. Drawing Machines Speed = 1/time Speed = constant