Arduino Code on Github
https://github.com/alastairhm/arduino
Doodle's Geek Monkey by Alastair Montgomery
Dusting off the iron
My first attempt at soldering after around eight years away from the soldering iron.
Counting up to 1023
Using the sketch below get the results shown in the video.
int numLed = 10; int ledpins[] = { 13,12,11,10,9,8,7,6,5,4}; int mask[] = { 1,2,4,8,16,32,64,128,256,512}; int counter = 0;void setup() {
// initialize the digital pin as an output. for (int i=0;i<numLed;i++){ pinMode(ledpins[i], OUTPUT); digitalWrite(ledpins[i], HIGH); delay(250); } }
Arduino Binary second counter
Basic using the LED Bar Graph or six single LEDs to count seconds in binary
/* Binary Second Counter Created Alastair Montgomery 22/11/2012 */int ledPins[] = { 7,8,9,10,11,12}; int mask[] = { 1,2,4,8,16,32}; int ledCount = 6;
void setup() { for (int thisPin =0; thisPin < ledCount; thisPin++) { pinMode(ledPins[thisPin], OUTPUT); } }
Sanity Checking my new Arduino Uno Board
Quick sanity check of my new Arduino board using a LED Bar Graph.
Here is the sketch I will be using.
int led1 = 8; int led2 = 9; int counter = 0;void setup() {
// initialize the digital pin as an output. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT);
}void loop() {
if (counter & 1) { digitalWrite(led1, HIGH); } else { digitalWrite(led1, LOW); }
Bashing about the command line
Doodle's Geek Monkey by Alastair Montgomery
Using Ruby to send commands over SSH
Doing a lot of work on remote Linux servers lately, lots of login in over SSH running commands logging out.
So wrote this simple script to use Ruby to send a single command or a file of commands to a Linux server over SSH. Needs some error trapping etc but functional at the moment.
It requires the Ruby Gem net-ssh installed.
#!/usr/bin/ruby
require 'rubygems'
require 'net/ssh'
require 'optparse'
opts = OptionParser.new
opts.on("-h HOSTNAME", "--hostname NAME", String, "Hostname of Server") { |v| @hostname = v }
opts.on("-u SSH USERNAME", "--username SSH USERNAME", String, "SSH Username of Server") { |v| @username = v }
opts.on("-p SSH PASSWORD", "--password SSH PASSWORD", String, "SSH Password of Server") { |v| @password = v }
opts.on("-c SHELL_COMMAND", "--command SHELL_COMMAND", String, "Shell Command to Execute") { |v| @cmd = v }
opts.on("-f FILE_COMMAND", "--command FILE_COMMAND", String, "File containing shell Commands to Execute") { |v| @fileCmd = v }
begin
opts.parse!(ARGV)
rescue OptionParser::ParseError => e
puts e
end
raise OptionParser::MissingArgument, "Hostname [-h]" if @hostname.nil?
raise OptionParser::MissingArgument, "SSH Username [-u]" if @username.nil?
raise OptionParser::MissingArgument, "SSH Password [-p]" if @password.nil?
raise OptionParser::MissingArgument, "Command to Execute [-c/-f]" if @cmd.nil? and @fileCmd.nil?
begin
ssh = Net::SSH.start(@hostname, @username, :password => @password)
if @cmd != nil then
ssh.exec!(@cmd) do |ch, stream, data|
if stream == :stderr
puts "ERROR: #{data}"
else
puts data
end
end
else
puts "Processing file #{@fileCmd}"
file = File.new(@fileCmd, "r")
file.each {|line|
ssh.exec!(line) do |ch, stream, data|
if stream == :stderr
puts "ERROR: #{data}"
else
puts data
end
end
}
file.close
end
ssh.close
rescue Exception => e
puts "Unable to connect to #{@hostname} using #{@username}/#{@password}"
puts e
end
Doodle's Geek Monkey by Alastair Montgomery
3d Printing the future
Note: 1 of this post’s 7 links are now broken — mostly dead 2008–2013 feed-syndication infrastructure (FeedBurner, Gawker, AOL’s old blog network, Pheedo, Yahoo Pipes). Left as originally published.
First boot
http://instagr.am/p/MOCHVnN-hg/
First boot of my Raspberry Pi.
Feel like I'm ten again sat in front of the TV with my Acorn Electron
Raspberry Pi SD Card problems
Was going to fire up my Raspberry Pi for the first time yesterday but had issues creating boot SD card for it on Windows 7. As you can see here from my post at the Pi Forum.
Looks like it was either problems with my desktop or the SD Card reader I was using as it was getting write errors when using the two Windows methods of creating the boot image.
Hopefully I can get the SD card reformat with GParted so I can try again, most annoying that I tripped up at the first hurdle.
Doodle's Geek Monkey by Alastair Montgomery

