week16 changed

parent 218a0a5d
Pipeline #105790 passed with stage
......@@ -136,7 +136,57 @@ print (result)
<p>I first downloaded processing from the Processing <a href="https://processing.org/download/ ">download page</a>. According to their page, 'Processing' is a flexible software sketchbook and a language for learning how to code within the context of the visual arts. I followed some <a href="https://processing.org/tutorials/ ">tutorials </a>to get to know about the Processing. </p>
<p>Then I got Ivan's code and tried to understand it specifically.
The Serial port had to be changed in the code initially. The data I send from the serial line will be in ASCII format. Here I used FTDI cable to send the data to the PC from the serial port. Then I tried to change the colors of the window and the texts according to my needs. The graph of the program updates everytime I receive a new value from the sensor.</p>
The Serial port had to be changed in the code initially. The data I send from the serial line will be in two bytes + preamble.</p>
<p>The ADC reads the data from the sensor and encode it in 10 bits. This data are in registers ADCL and ADCH <br>
The code store these 10 bits in two bytes</p>
<pre><code>hr = ADCL;
put_char(&serial_port, serial_pin_out, chr);
char_delay();
chr = ADCH;
put_char(&serial_port, serial_pin_out, chr);
char_delay();
</code></pre>
<p>In the Processing code I decode this byte and store it in a int:</p><br>
<code>int counter = ((256*high)+low);</code><br><br>
<p><code>counter </code>is the value that is present in the graph.</p>
<p>In addition, I'm sending a preamble of 4 bytes before each data frame. The bytes are <code>1</code>,<code> 2</code>,<code> 3</code>,<code> 4</code></p>
<pre><code>put_char(&serial_port, serial_pin_out, 1);
char_delay();
put_char(&serial_port, serial_pin_out, 2);
char_delay();
put_char(&serial_port, serial_pin_out, 3);
char_delay();
put_char(&serial_port, serial_pin_out, 4);
char_delay();
</code></pre>
<br><p>That will be checked in your Processing code:</p>
<p><code>if ((byte1 == 1) & (byte2 == 2) & (byte3 == 3) & (byte4 ==4)){
//Reset the preamble.
</code>
<br></p>
<p> Here I used FTDI cable to send the data to the PC from the serial port. Then I tried to change the colors of the window and the texts according to my needs. The graph of the program updates everytime I receive a new value from the sensor.</p>
<pre><code>void updateGraph(int value){
distance = value;
//Add the point to the graph
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment