<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN">
		<id>http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Somatosensory_interaction_-_ultrasound</id>
		<title>Somatosensory interaction - ultrasound - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http:///https//wiki.microduino.cn/index.php?action=history&amp;feed=atom&amp;title=Somatosensory_interaction_-_ultrasound"/>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Somatosensory_interaction_-_ultrasound&amp;action=history"/>
		<updated>2026-06-14T07:18:50Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https//wiki.microduino.cn/index.php?title=Somatosensory_interaction_-_ultrasound&amp;diff=2732&amp;oldid=prev</id>
		<title>Pkj：Created page with &quot;{{Language | 体感互动-超声波}} {| style=&quot;width: 800px;&quot; |- | ==Objective== This turorial will display a distance that ultrasonic sensor measured in Processing with a cu...&quot;</title>
		<link rel="alternate" type="text/html" href="https//wiki.microduino.cn/index.php?title=Somatosensory_interaction_-_ultrasound&amp;diff=2732&amp;oldid=prev"/>
				<updated>2014-05-19T13:07:33Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Language | 体感互动-超声波}} {| style=&amp;quot;width: 800px;&amp;quot; |- | ==Objective== This turorial will display a distance that ultrasonic sensor measured in Processing with a cu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Language | 体感互动-超声波}}&lt;br /&gt;
{| style=&amp;quot;width: 800px;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Objective==&lt;br /&gt;
This turorial will display a distance that ultrasonic sensor measured in Processing with a curve.&lt;br /&gt;
&lt;br /&gt;
==Equipment==&lt;br /&gt;
*'''[[Microduino-Core]]'''&lt;br /&gt;
*'''[[Microduino-FT232R]]'''&lt;br /&gt;
*Other equipment&lt;br /&gt;
**USB cable           one  &lt;br /&gt;
**Ultrasonic sensor   one&lt;br /&gt;
**The magnet          one&lt;br /&gt;
**330Ω resistor       one&lt;br /&gt;
**Bread               one&lt;br /&gt;
**Breadboard Jumper   onebox&lt;br /&gt;
&lt;br /&gt;
==Schematic==&lt;br /&gt;
&lt;br /&gt;
[[File:interactionUltrasonicSchematics.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Program==&lt;br /&gt;
&lt;br /&gt;
Refers to  interactionUltrasonic&lt;br /&gt;
interactionUltrasonicArduino&lt;br /&gt;
&lt;br /&gt;
==Debug==&lt;br /&gt;
Step 1：Set up hardware system, as follows:&lt;br /&gt;
[[File:interactionUltrasonicConnectionDiagram.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
Step 2: Explain the code:&lt;br /&gt;
&lt;br /&gt;
This example needs two parts code, one is Processing and the other is Microduino.&lt;br /&gt;
&lt;br /&gt;
Microduino:&lt;br /&gt;
&lt;br /&gt;
//Calculate the distance and output to serial for Processing's display.&lt;br /&gt;
  void loop()&lt;br /&gt;
  {&lt;br /&gt;
    digitalWrite(TrigPin, LOW);&lt;br /&gt;
    delayMicroseconds(2);&lt;br /&gt;
    digitalWrite(TrigPin, HIGH);&lt;br /&gt;
    delayMicroseconds(10);&lt;br /&gt;
    digitalWrite(TrigPin, LOW);&lt;br /&gt;
  &lt;br /&gt;
    cm = pulseIn(EchoPin, HIGH) / 58.0; //Echo time will be converted into cm&lt;br /&gt;
    cm = (int(cm * 100.0)) / 100.0; //Two decimal places&lt;br /&gt;
    Serial.println(cm);&lt;br /&gt;
    delay(100);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Processing:&lt;br /&gt;
&lt;br /&gt;
//Get the the first serial data,&lt;br /&gt;
// is always my  Arduino, so I open Serial.list()[0].&lt;br /&gt;
// Open whatever port is the one you're using.&lt;br /&gt;
  myPort = new Serial(this, Serial.list()[0], 9600);&lt;br /&gt;
  myPort.bufferUntil('\n'); // Trigger a SerialEvent on new line&lt;br /&gt;
&lt;br /&gt;
//Use the curve to display the data that Microduino sent using the curve and mark the table scale&lt;br /&gt;
  void draw() {&lt;br /&gt;
    background(255);&lt;br /&gt;
    // Draw lines connecting all points&lt;br /&gt;
    for (int i = 0; i &amp;lt; vals.length-1; i++) {&lt;br /&gt;
      stroke(0);&lt;br /&gt;
      strokeWeight(1);&lt;br /&gt;
      line(i, vals[i], i+1, vals[i+1]);&lt;br /&gt;
    }&lt;br /&gt;
    // Slide everything down in the array&lt;br /&gt;
    for (int i = 0; i &amp;lt; vals.length-1; i++) {&lt;br /&gt;
      vals[i] = vals[i+1];&lt;br /&gt;
    }&lt;br /&gt;
    // Add a new random value&lt;br /&gt;
    //vals[vals.length-1] = random(height);&lt;br /&gt;
    String val = myPort.readStringUntil('\n');&lt;br /&gt;
    if (val != null) {&lt;br /&gt;
      val = trim(val);&lt;br /&gt;
      println(val);&lt;br /&gt;
      cm=Float.parseFloat(val);&lt;br /&gt;
    }&lt;br /&gt;
    vals[vals.length-1] = 200-cm;&lt;br /&gt;
    //Display scale&lt;br /&gt;
    text ( &amp;quot;200-&amp;quot;, 370, 10); &lt;br /&gt;
    text ( &amp;quot;--&amp;quot;, 370, 50); &lt;br /&gt;
    text ( &amp;quot;100-&amp;quot;, 370, 100);&lt;br /&gt;
    text ( &amp;quot;--&amp;quot;, 370, 150); &lt;br /&gt;
    text ( &amp;quot;0-&amp;quot;, 370, 200); &lt;br /&gt;
    //show current num&lt;br /&gt;
    text ( cm, 0, 10);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Step 3: Compile the code and download it.&lt;br /&gt;
&lt;br /&gt;
Step 4: Runing the program and put an object in front of the ultrasonic sensor, then observe the Processing's output.&lt;br /&gt;
&lt;br /&gt;
==Result==&lt;br /&gt;
Screen will display the distance data curve, as follows:&lt;br /&gt;
[[File:interactionUltrasonicResult.jpg|600px|center|thumb]]&lt;br /&gt;
&lt;br /&gt;
==Vidoe==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pkj</name></author>	</entry>

	</feed>