-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #93 #167
fixes #93 #167
Changes from 2 commits
9812c13
353c57c
4fb0e69
7eee20b
d57b665
d9d85c4
f51aa85
2374271
93f16f7
1be6997
41d92eb
a9f5db0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,61 @@ If you're newer to hardware and these functions look like alphabet soup to you, | |
|
||
By default, all of the pins are pulled high if not specifically set. | ||
|
||
### Pullup and Pulldown pins | ||
|
||
Pins 2-7 on both Ports are available for pullup and pulldown. | ||
|
||
The basic function of a pull-up resistor is to insure that given no other input, a circuit assumes a default value. The 'pullup' mode pulls the line high and the 'pulldown' mode pulls it low. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: "insure" -> "ensure" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, this is a lovely description. Can you add "pullup" and "pulldown" to the docs glossary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
|
||
### Usage | ||
```js | ||
// Invoke this method to set the pull mode. pullType can be - pullup, pulldown or none. | ||
pin.pull(pullType, callback); | ||
``` | ||
|
||
Example of the `pin.pull(mode)` command using a pushbutton. The code example given below turns on the Blue LED of the Tessel module when the pushbutton is pressed and turns off the Blue LED when the pushbutton is released. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just say [Learn more about using the Pullup / Pulldown API.](/Tutorials/pinpull.html) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
```js | ||
var tessel= require('tessel'); // Import Tessel | ||
|
||
var pin = tessel.port.A.pin[2]; // Select pin 2 on port A | ||
|
||
var pullType = "pullup"; // Set the mode of `pin.pull to pullup` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to single quotes, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (This code now resides in Tutorials) |
||
|
||
var led = tessel.led[3]; // Blue LED of Tessel | ||
|
||
pin.pull(pullType,(error, buffer) => { // Pin 2 pulled high | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know what the value of that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're trying to check manually by making the circuit. |
||
|
||
if (error){ | ||
throw error; | ||
} | ||
}); | ||
|
||
setInterval({ | ||
pin.read(function(error, number){ | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
|
||
// Pin 2 reads high when the pushbutton is not pressed since it is pulled up | ||
console.log(number); | ||
if (number == 1){ | ||
led.off(); | ||
} | ||
|
||
// Pin 2 reads low when the pushbutton is pressed since its connection with ground gets complete | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggest changing phrasing "gets complete" to "is completed" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done (The code now resides in "Tutorials") |
||
else{ | ||
led.on(); | ||
} | ||
|
||
}); | ||
|
||
}, 500); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this var tessel= require('tessel'); // Import Tessel
var pin = tessel.port.A.pin[2]; // Select pin 2 on port A
pin.pull('pullup', (error, buffer) => { // Pin 2 pulled high
if (error) {
throw error;
}
console.log(buffer.toString()) // what should this be?
} displays how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! This looks better for a basic code demonstration :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
``` | ||
|
||
|
||
|
||
### Digital pins | ||
|
||
A digital pin is either high (on/3.3V) or low (off/0V). Any pin on both ports A and B, other than 3.3V and GND, can be used be used as a digital pin. All pins are pulled high to 3.3V by default. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Pull- Pins | ||
|
||
Suppose a pin is configured as an input. If nothing is connected to the pin and the program tries to read the state of the pin, it would be in a 'floating' state i.e an unknown state. To prevent this, a pull-up or a pull-down state is defined. They are often used in the case of Buttons and Switches. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "pull-up" and "pullup" are both used in this PR, but it would be better to choose a standard. I think hyphenated is standard, but haven't researched this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes indeed. Hyphenated is standard. Will edit it everywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hyphenated is now used in the text as per wikipedia (https://en.wikipedia.org/wiki/Pull-up_resistor) but non-hyphenated is the default arg value in the firmware, so we can't change it in the text. |
||
|
||
Pins 2-7 on both the Ports are available for interrupts. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "...available for interrupts" – did you mean to say pull-up and pull-down instead of interrupts? |
||
|
||
Take a look at the following circuit. The code example given below turns on the Blue LED of the Tessel module when the pushbutton is pressed and turns off the Blue LED when the pushbutton is released. | ||
|
||
![Pin-Pull using Push buttons](http://i.imgur.com/OYJZ8Dp.jpg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice Fritzing! 👏 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! @mittalshravika at it :) |
||
|
||
```js | ||
var tessel= require('tessel'); // Import Tessel | ||
|
||
var pin = tessel.port.A.pin[2]; // Select pin 2 on port A | ||
|
||
var pullType = "pullup"; // Set the mode of `pin.pull to pullup` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "pullup" vs "pull-up" in comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "pullup" is the default arg value as defined in the t2-firmware code here : https://github.com/tessel/t2-firmware/blob/master/node/tessel-export.js#L737-L758 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. backtick is in the wrong place, should end backtick quotes after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
var led = tessel.led[3]; // Blue LED of Tessel | ||
|
||
pin.pull(pullType,(error, buffer) => { // Pin 2 pulled high | ||
|
||
if (error){ | ||
throw error; | ||
} | ||
}); | ||
|
||
setInterval({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
To fix this: setInterval(() => {
... // call pin.read
}, 500); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this! :) |
||
pin.read(function(error, number){ | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
|
||
// Pin 2 reads high when the pushbutton is not pressed since it is pulled up | ||
console.log(number); | ||
if (number == 1){ | ||
led.off(); | ||
} | ||
|
||
// Pin 2 reads low when the pushbutton is pressed since its connection with ground gets complete | ||
else{ | ||
led.on(); | ||
} | ||
|
||
}); | ||
|
||
}, 500); | ||
``` | ||
[More Information on Pull-up pins and resistors](https://learn.sparkfun.com/tutorials/pull-up-resistors) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Information should not be capitalized There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional, might be useful to mention that the link goes to Sparkfun or otherwise designate it as an external (non-Tessel) link There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice description. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! :)