...
 
Commits (2)
// Example by Tom Igoe
int state=0;
float x=0, y=200, xSpeed=2, ySpeed=2 ;
void setup() {
size(800,400);
}
void mousePressed() {
if (mousePressed) {
state = 1; // state game
}
else {
state = 0; // state exit
}
}
void draw() {
if (state==0) {
textSize(30);
textAlign(CENTER);
text("Click to Start and press a letter", 400, 30);
fill(0, 102, 153);
}
else if (state==1) {
fill(random(100),random(255),random(255));
x += xSpeed;
y += ySpeed;
if (x > width || x < 0 ){
xSpeed *= -1;
}
ellipse(x, y, 50, 50);
if (keyPressed){
ySpeed = -2;
}
else{
ySpeed = 2;
}
}
}
......@@ -32,7 +32,7 @@
<!-- Content -->
<section>
<header class="main">
<h1>Solar Tracker --- Արևին հետևող համակարգ</h1>
<h1>Solar Tracker --- Արևին հետևող</h1>
</header>
<!-- <div style="text-align: center;"><iframe width="853" height="480"
src="https://www.youtube.com/embed/l9b_6WLemmg" frameborder="0"
......@@ -42,7 +42,7 @@
<!-- <a href=""></a> -->
<h2>Introduction --- Ներածություն</h2>
<p>I finally decided what to make for my final project. It was really hard for me to choose what to
make. But finnaly I decided to make a <a
make. But finally I decided to make a <a
href="https://en.wikipedia.org/wiki/Solar_tracker">solar tracking system</a>.
It should be able to track sun's movement with two axis.
I found this <a href="">machine design</a> assignment from fablabbccn fabacademy2017 </p>
......
<!DOCTYPE HTML>
<!--
Editorial by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
<head>
<title>Week16</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="../assets/css/main-weekly.css" />
</head>
<body class="is-preload">
<!-- Wrapper -->
<div id="wrapper">
<!-- Main -->
<div id="main">
<div class="inner">
<!-- Header -->
<header id="header">
<a href="../index.html" class="logo"><strong>Week 16</strong> by Babken Chugaszyan</a>
</header>
<img src="../images/Border.png" alt="" />
<!-- Content -->
<section>
<header class="main">
<h1>Interface and Application Programming --- </h1>
</header>
<!-- <div style="text-align: center;"><iframe width="853" height="480"
src="https://www.youtube.com/embed/l9b_6WLemmg" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe></div> -->
<!-- <span class="image main"><img src="../images/" alt="" /></span> -->
<!-- <a href=""></a> -->
<h2>Introduction --- Ներածություն</h2>
<p>For this week we had to:
<br> write an application that interfaces a user with an
input &/or output device that you made. (individual assignment)
<br>I will try to make an application using <a href="https://processing.org/">Processing</a>
that will communicate with my <a href="./week11.html">input devices</a> week
boards via <a
href="http://fab.cba.mit.edu/classes/863.16/doc/projects/FabFTDI/FabFTDI.html">FabFTDI</a>.
<h3>Installing Processing 3.5.3 on Linux --- </h3>
<p>Go to <a href="https://processing.org/download/">Processing Download</a> page select the
correct linux version you need (32bit 64bit).
At this point a download should start and you will get a <b>.tgz</b> archive. Extract it in
your "home" directory. After done open the
Processing 3.5.3 folder in your home directory, right click and select "Open in Terminal".
Type <code>./processing</code> and hit enter. At this point you should get Processing
working. If not visit <a href="https://github.com/processing/processing/wiki/Supported-Platforms">Supported-Platforms</a>
page for solutions. If you are going to access Serial ports type <code>sudo ./processing</code> otherwise you
will get this error:
<br><b>Error opening serial port /dev/ttyACM1: Permission denied.</b>
</p>
<h3>Using Processing 3.5.3 --- </h3>
<p>The default coding language in processing is Java, but you can change it easily by pressing
the "Java" buttun at the right upper corner.
There are lot of <a href="https://processing.org/tutorials/">tutorials</a> and <a
href="https://processing.org/examples/">examples</a> you can use and learn with for
processing.
I started with setting up serial communication and with my FabFTDI and reading data from
button board I made during <a href="./week11.html">Input Devices</a> week. My button board sends "b" when button pressed and "u" when released.
I used the default example for serial read.
<br>// Example by Tom Igoe
<br><code>import processing.serial.*;</code> // imports serial library
<br><code>Serial myPort;</code> // The serial port
<br><code>void setup() {</code>
<br>// Open the port you are using at the rate you want:
<br><code>myPort = new Serial(this, Serial.list()[0], 4800);}</code> // default baudrate is 9600 but FabFTDI supports up to 4800.
<br><code>void draw() {</code> // <b>draw()</b> loops forever, until stopped.
<br><code>while (myPort.available() > 0) {</code> // <b>myPort.available()</b> Returns the number of bytes available.
<br><code>int inByte = myPort.read();</code> // <b>myPort.read()</b> Returns a number between 0 and 255 for the next byte that's waiting in the buffer.
<br><code>println(inByte);}}</code> // prints the value of <b>inByte</b>.
<br>To run the program you should save it and hit the play buttun at the upper left corner. Now press the button on the board and you will get something like this.
<span class="image main"><img src="../images/" alt="" /></span>
<br>I changed the second-to-last line of the program to this:
<br><code>char inByte = myPort.readChar();</code> // Returns the next byte in the buffer as a char.
<br>And got this.
<span class="image main"><img src="../images/" alt="" /></span>
<p>After watching and reading some tutorials I came across the <a href="https://youtu.be/U5cOB3KgFWQ">Bouncing Ball</a> tutorial and decides to make a simple game where a ball tries to go down
and by pressing the button it goes up. The goal is to keep the ball away from the ground.</p>
</p>
<h3>Screen printing --- Տպագրում մաղով</h3>
<canvas data-src ="ball.pde"></canvas>
<p>.</p> <a href="/cad files/week16/ball.pde"></a>
<p>Anyway Gevorg was very happy with the result.</p>
<!-- <a href=""></a> -->
</section>
</div>
</div>
</div>
</div>
</div>
<!-- Scripts -->
<script type="text/javascript" src="../cad files/week16/processing.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="../assets/js/browser.min.js"></script>
<script src="../assets/js/breakpoints.min.js"></script>
<script src="../assets/js/util.js"></script>
<script src="../assets/js/main-weekly.js"></script>
</body>
</html>
\ No newline at end of file
import processing.serial.*;
Serial myPort;
float x=0, y=300, xSpeed=2, ySpeed=2 ;
void setup() {
size(800,400);
myPort = new Serial(this, Serial.list()[0], 4800);
}
void draw() {
fill(random(100),random(255),random(255));
x += xSpeed;
y += ySpeed;
if (x > width || x < 0 ){
xSpeed *= -1;
}
ellipse(x, y, 50, 50);
while (myPort.available() > 0) {
char inByte = myPort.readChar();
println(inByte);
if (inByte == 'b' || keyPressed){
ySpeed = -2;
}
else{
ySpeed = 2;
}
}
}
int state=0;
float x=0, y=200, xSpeed=2, ySpeed=2 ;
void setup() {
size(800,400);}
void mousePressed() {
if (mousePressed) {
state = 1; } // start
else {
state = 0; }}// wait
void draw() {
if (state==0) {
textSize(30);
textAlign(CENTER);
text("Click to Start and press a letter", 400, 30);
fill(0, 102, 153);}
else if (state==1) {
fill(random(100),random(255),random(255));
x += xSpeed;
y += ySpeed;
if (x > width || x < 0 ){
xSpeed *= -1;}
ellipse(x, y, 50, 50);
if (keyPressed){
ySpeed = -2;}
else{
ySpeed = 2;}}}
This diff is collapsed.