A Pen by Mikael Levén on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rpio = require('rpio'); | |
var rxBuffer = rpio.spiTransfer(new Buffer('HELLOSPI'), 8); | |
for (var i = 0; i <= 7; i++) { | |
process.stdout.write(String.fromCharCode(rxBuffer[i]) + (i == 7 ? '\n' : ' ')); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rpio = require('rpio'); | |
rpio.spiBegin(); | |
//rpio.spiChipSelect(0); /* Chip select: use CE0 (default) */ | |
//rpio.spiSetCSPolarity(0, rpio.LOW) /* Commonly chip enable (CE) pins are active low, and this is the default. */ | |
//rpio.spiSetClockDivider(256) /* MCP3008 max is ~1MHz, 256 == 0.98MHz */ | |
//rpio.spiSetDataMode(0); | |
// Prepare TX buffer [trigger byte = 0x01] [channel 0 = 0x80 (128)] [placeholder = 0x01] | |
var sendBuffer = new Buffer([0x01, (8 + 0 << 4), 0x01]); |
This is a simple script that reads all eight analog channels of an MCP3008 each second and outputs the result to the console.
I created this script to ease debugging of the MCP3008 ADC connected to my Raspberry Pi.
If you need to troubleshoot the SPI connection in itself you can check out my guide how to test SPI through the loopback "debug mode" https://mikaelleven.wordpress.com/2015/12/10/troubleshooting-spi-on-raspberry-pi-nodejs/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
# ALLOW-SSH SCRIPT # | |
# Author: Mikael Levén # | |
############################################################################### | |
# What this script basically does: # | |
# 1. Reads your SSH key # | |
# 2. Logins in to the remote server # | |
# 3. Creates a new user using your current username # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.btn-success2 | |
{ | |
display: inline-block; | |
height: 36px; | |
max-width: 100%; | |
overflow: hidden; | |
padding: 0 15px; | |
background-color: #c45e12; | |
border: none; | |
border-radius: 3px; |