<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.extremist.software/index.php?action=history&amp;feed=atom&amp;title=EBB_Notes_2</id>
	<title>EBB Notes 2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.extremist.software/index.php?action=history&amp;feed=atom&amp;title=EBB_Notes_2"/>
	<link rel="alternate" type="text/html" href="https://wiki.extremist.software/index.php?title=EBB_Notes_2&amp;action=history"/>
	<updated>2026-04-04T21:31:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.extremist.software/index.php?title=EBB_Notes_2&amp;diff=16787&amp;oldid=prev</id>
		<title>Rbelknap: adding category tag</title>
		<link rel="alternate" type="text/html" href="https://wiki.extremist.software/index.php?title=EBB_Notes_2&amp;diff=16787&amp;oldid=prev"/>
		<updated>2011-02-25T22:26:41Z</updated>

		<summary type="html">&lt;p&gt;adding category tag&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:26, 25 February 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l234&quot;&gt;Line 234:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 234:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Sensebridge]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Rbelknap</name></author>
	</entry>
	<entry>
		<id>https://wiki.extremist.software/index.php?title=EBB_Notes_2&amp;diff=4183&amp;oldid=prev</id>
		<title>Rachel: New page: Rachel &amp; Mike, March 30(?); Rachel April 1 - 5  Next we tried the MaxSonar-EZ1 device.  Someone else has hooked it up to an arduino and posted code: http://www.flatline.net/journal/2007/12...</title>
		<link rel="alternate" type="text/html" href="https://wiki.extremist.software/index.php?title=EBB_Notes_2&amp;diff=4183&amp;oldid=prev"/>
		<updated>2009-04-06T14:46:47Z</updated>

		<summary type="html">&lt;p&gt;New page: Rachel &amp;amp; Mike, March 30(?); Rachel April 1 - 5  Next we tried the MaxSonar-EZ1 device.  Someone else has hooked it up to an arduino and posted code: http://www.flatline.net/journal/2007/12...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Rachel &amp;amp; Mike, March 30(?); Rachel April 1 - 5&lt;br /&gt;
&lt;br /&gt;
Next we tried the MaxSonar-EZ1 device.  Someone else has hooked it up to an arduino and posted code: http://www.flatline.net/journal/2007/12/02/arduino-reading-the-maxbotix-ultrasonic-rangefinder/ which was a useful reference.&lt;br /&gt;
&lt;br /&gt;
This appears to work slightly better than the PING))) but still shows false negatives at more than about 3 feet.  Here&amp;#039;s some functional code that pwm&amp;#039;s an LED, where the closer the object the brighter the LED.  Tweaking would be good as the flashing is fairly noticable, but since this will drive a motor eventually I don&amp;#039;t see the point in making it too tiny of a cycle length.  EZ-1&amp;#039;s analog pin hooked to Arduino&amp;#039;s A0 pin &amp;amp; its +5 and ground pins connected to the Arduino 5V and grounds. The LED&amp;#039;s + leg is connected, with a 33ohm resistor, to pin D11; - leg is connected to pin D13 (and I don&amp;#039;t quite get this, why not to ground? maybe that would work too? haven&amp;#039;t tried)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
int analogPin = 0;&lt;br /&gt;
int ledPin = 11;&lt;br /&gt;
int serialPin = 2;&lt;br /&gt;
double fullCycle = 50; // cycle time in millis&lt;br /&gt;
&lt;br /&gt;
void setup()                    // run once, when the sketch starts&lt;br /&gt;
{&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  pinMode(ledPin, OUTPUT);&lt;br /&gt;
  pinMode(analogPin, INPUT);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()                     // run over and over again&lt;br /&gt;
{&lt;br /&gt;
  // read the voltage&lt;br /&gt;
  int something = analogRead(analogPin);&lt;br /&gt;
  double volts = something * .0049;&lt;br /&gt;
&lt;br /&gt;
  // convert voltage into distance&lt;br /&gt;
  double VperInch = 9.8 / 1000;&lt;br /&gt;
  double inches = volts / VperInch;&lt;br /&gt;
  &lt;br /&gt;
  Serial.print(volts);&lt;br /&gt;
  Serial.print(&amp;quot;V; &amp;quot;);&lt;br /&gt;
  Serial.print(inches);&lt;br /&gt;
  Serial.print(&amp;quot;in&amp;quot;);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
  &lt;br /&gt;
  delay(1);&lt;br /&gt;
&lt;br /&gt;
  double dutyCycle = generateDutyCycle(inches);&lt;br /&gt;
  Serial.print(dutyCycle);&lt;br /&gt;
  Serial.println(&amp;quot;% on&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  pwm(dutyCycle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
double generateDutyCycle(double inches) {&lt;br /&gt;
  // 6 inches, the closest distance this sensor can read, defined as full power&lt;br /&gt;
  // 10 feet, our supposed max distance, defined as no power&lt;br /&gt;
  int minDist = 6;&lt;br /&gt;
  int maxDist = 120;&lt;br /&gt;
  &lt;br /&gt;
  // limit values to our defined range&lt;br /&gt;
  if( inches &amp;gt; maxDist ) {&lt;br /&gt;
    inches = maxDist;&lt;br /&gt;
  }&lt;br /&gt;
  if( inches &amp;lt; minDist ) {&lt;br /&gt;
    inches = minDist;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // translate the passed value to a percentage, accounting for the fact that&lt;br /&gt;
  // the range does not start at 0.  we don&amp;#039;t really care EXACTLY where it ends, though&lt;br /&gt;
  double adjustedInches = inches - minDist;&lt;br /&gt;
  int totalRange = maxDist - minDist;&lt;br /&gt;
  return (totalRange - adjustedInches) / totalRange;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void pwm(double onCycle)&lt;br /&gt;
{&lt;br /&gt;
  double offCycle = 1 - onCycle;&lt;br /&gt;
  Serial.print(&amp;quot;onCycle &amp;quot;);&lt;br /&gt;
  Serial.print(onCycle);&lt;br /&gt;
  Serial.print(&amp;quot;; offCycle &amp;quot;);&lt;br /&gt;
  Serial.print(offCycle);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
&lt;br /&gt;
  // fullCycle is the full cycle time in millis (what is this called again?)&lt;br /&gt;
  long onTime = onCycle * fullCycle;&lt;br /&gt;
  long offTime = offCycle * fullCycle;&lt;br /&gt;
&lt;br /&gt;
  Serial.print(&amp;quot;on for &amp;quot;);&lt;br /&gt;
  Serial.print(onTime);&lt;br /&gt;
  Serial.print(&amp;quot;; off for &amp;quot;);&lt;br /&gt;
  Serial.print(offTime);&lt;br /&gt;
  Serial.println();&lt;br /&gt;
&lt;br /&gt;
  if( onTime &amp;gt; 0 ) {&lt;br /&gt;
    digitalWrite(ledPin, HIGH);&lt;br /&gt;
    delay(onTime);&lt;br /&gt;
  }&lt;br /&gt;
  if( offTime &amp;gt; 0 ) {&lt;br /&gt;
    digitalWrite(ledPin, LOW);&lt;br /&gt;
    delay(offTime);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the serial attempt, with several different read methods, none of which do what is expected.  It is possible that the sensor is fried; I didn&amp;#039;t get analog readings after giving up on serial, and then swapped it out for the other, which I could read.  I haven&amp;#039;t tried the serial code on the other EZ-1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// based on code by:&lt;br /&gt;
//Created August 15 2006&lt;br /&gt;
//Heather Dewey-Hagborg&lt;br /&gt;
//http://www.arduino.cc&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;ctype.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define bit9600Delay 84  &lt;br /&gt;
#define halfBit9600Delay 42&lt;br /&gt;
#define bit4800Delay 188 &lt;br /&gt;
#define halfBit4800Delay 94 &lt;br /&gt;
&lt;br /&gt;
//byte rx = 3;&lt;br /&gt;
//byte tx = 2;&lt;br /&gt;
byte rx = 2;&lt;br /&gt;
byte tx = 3;&lt;br /&gt;
byte SWval;&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  Serial.begin(9600);&lt;br /&gt;
  Serial.print(&amp;quot;hi&amp;quot;);  //debugging hello&lt;br /&gt;
  pinMode(rx,INPUT);&lt;br /&gt;
  pinMode(tx,OUTPUT);&lt;br /&gt;
  digitalWrite(tx,LOW);&lt;br /&gt;
  delay(2);&lt;br /&gt;
//  digitalWrite(13,HIGH); //turn on debugging LED&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  Serial.print(&amp;quot;&amp;gt; &amp;quot;);&lt;br /&gt;
  // first poke it to get a reading&lt;br /&gt;
  digitalWrite(tx,HIGH);&lt;br /&gt;
  delayMicroseconds(50);&lt;br /&gt;
  digitalWrite(tx,LOW);&lt;br /&gt;
&lt;br /&gt;
  // next read the value&lt;br /&gt;
  SWval = SWread();&lt;br /&gt;
&lt;br /&gt;
  // print out the value&lt;br /&gt;
  Serial.print(SWval);&lt;br /&gt;
  Serial.print(&amp;quot; &amp;quot;);&lt;br /&gt;
  Serial.println((int)SWval);&lt;br /&gt;
    &lt;br /&gt;
  // delay a tenth of a second&lt;br /&gt;
//  delay(100);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int SWreadWithInversion()&lt;br /&gt;
{&lt;br /&gt;
  byte val = 0;&lt;br /&gt;
  while (digitalReadInv(rx));&lt;br /&gt;
  //wait for start bit&lt;br /&gt;
  if (digitalReadInv(rx) == LOW) {&lt;br /&gt;
    delayMicroseconds(halfBit9600Delay);&lt;br /&gt;
    for (int offset = 0; offset &amp;lt; 8; offset++) {&lt;br /&gt;
      delayMicroseconds(bit9600Delay);&lt;br /&gt;
      val |= digitalReadInv(rx) &amp;lt;&amp;lt; offset;&lt;br /&gt;
    }&lt;br /&gt;
    //wait for stop bit + extra&lt;br /&gt;
    delayMicroseconds(bit9600Delay); &lt;br /&gt;
    delayMicroseconds(bit9600Delay);&lt;br /&gt;
    return val;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int SWreadNotInverted()&lt;br /&gt;
{&lt;br /&gt;
  byte val = 0;&lt;br /&gt;
  while (digitalRead(rx));&lt;br /&gt;
  //wait for start bit&lt;br /&gt;
  if (digitalRead(rx) == HIGH) {&lt;br /&gt;
    delayMicroseconds(halfBit9600Delay);&lt;br /&gt;
    for (int offset = 0; offset &amp;lt; 8; offset++) {&lt;br /&gt;
      delayMicroseconds(bit9600Delay);&lt;br /&gt;
      val |= digitalRead(rx) &amp;lt;&amp;lt; offset;&lt;br /&gt;
    }&lt;br /&gt;
    //wait for stop bit + extra&lt;br /&gt;
    delayMicroseconds(bit9600Delay); &lt;br /&gt;
    delayMicroseconds(bit9600Delay);&lt;br /&gt;
    return val;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
byte digitalReadInv(byte port)&lt;br /&gt;
{&lt;br /&gt;
   switch(digitalRead(port))&lt;br /&gt;
   {&lt;br /&gt;
   case LOW:&lt;br /&gt;
       return HIGH;&lt;br /&gt;
&lt;br /&gt;
   case HIGH: default:&lt;br /&gt;
       return LOW;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int SWread()&lt;br /&gt;
{&lt;br /&gt;
  byte val = 0;&lt;br /&gt;
  while (digitalRead(rx));&lt;br /&gt;
  //wait for start bit&lt;br /&gt;
  if (digitalRead(rx) == LOW) {&lt;br /&gt;
    delayMicroseconds(halfBit9600Delay);&lt;br /&gt;
    for (int offset = 0; offset &amp;lt; 8; offset++) {&lt;br /&gt;
      delayMicroseconds(bit9600Delay);&lt;br /&gt;
      val |= digitalRead(rx) &amp;lt;&amp;lt; offset;&lt;br /&gt;
    }&lt;br /&gt;
    //wait for stop bit + extra&lt;br /&gt;
    delayMicroseconds(bit9600Delay); &lt;br /&gt;
    delayMicroseconds(bit9600Delay);&lt;br /&gt;
    return val;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void SWprint(int data)&lt;br /&gt;
{&lt;br /&gt;
  byte mask;&lt;br /&gt;
  //startbit&lt;br /&gt;
  digitalWrite(tx,LOW);&lt;br /&gt;
  delayMicroseconds(bit9600Delay);&lt;br /&gt;
  for (mask = 0x01; mask&amp;gt;0; mask &amp;lt;&amp;lt;= 1) {&lt;br /&gt;
    if (data &amp;amp; mask){ // choose bit&lt;br /&gt;
     digitalWrite(tx,HIGH); // send 1&lt;br /&gt;
    }&lt;br /&gt;
    else{&lt;br /&gt;
     digitalWrite(tx,LOW); // send 0&lt;br /&gt;
    }&lt;br /&gt;
    delayMicroseconds(bit9600Delay);&lt;br /&gt;
  }&lt;br /&gt;
  //stop bit&lt;br /&gt;
  digitalWrite(tx, HIGH);&lt;br /&gt;
  delayMicroseconds(bit9600Delay);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rachel</name></author>
	</entry>
</feed>