This might not be the best way... you should read this good one here as well..
//http://www.instructables.com/id/Arduino-Timer-Interrupts/
#define num_mins 2
#define LED 11
int COUNT = 1;
void setup(){
cli();//stop interrupts
//set timer1 interrupt at 0.25 Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = 4*15624;// = (16*10^6) / (4*1*1024) - 1 (must be <65536 )
// turn on CTC mode
TCCR1B |= (1 << WGM12); // from ATMEL datasheet
// Set CS10 and CS12 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);
sei();//allow interrupts
pinMode( LED, OUTPUT );
}//end setup
ISR(TIMER1_COMPA_vect){//timer1 interrupt 0.25 Hz increment the counter
COUNT = COUNT+1;
}
void loop(){
int trigger = num_mins * 15;
if( COUNT > trigger){
digitalWrite( LED, HIGH);
}
} // loop
Sunday, December 7, 2014
Friday, December 5, 2014
Das Arbeitets Wunderbar
http://rpi.tnet.com/project/faqs/smtp
mail or mpack do the trick. mpack can send a file
> echo test | mail -s "Subject" who@where
> mpack -s "test" who@where
Hmmm, worked okay for a day.. Now, I get :
pi@raspberrypi ~ $ send-mail: Authorization failed (534 5.7.9 https://support.google.com/mail/bin/answer.py?answer=78754 ko4sm35426303pdb.31 - gsmtp)
mail or mpack do the trick. mpack can send a file
> echo test | mail -s "Subject" who@where
> mpack -s "test"
pi@raspberrypi ~ $ send-mail: Authorization failed (534 5.7.9 https://support.google.com/mail/bin/answer.py?answer=78754 ko4sm35426303pdb.31 - gsmtp)
Was gebt?
I follow bonelifer's suggestion on http://www.raspberrypi.org/forums/viewtopic.php?f=36&t=46218
I go to the Security - Account Settings page and I find Access for Less secure Apps is already Enabled, and 2-Step ver is already disabled... So???
So, I turn ON 2-step verification and then, it (google account security website) magically tells me I can generate and app password, do so, put that in the ssmtp.conf and all is well...
Can You Run Raspberry Pi Off Your PC's USB Port?
Depends. Safe answer : "No"
I found out the hard way when Windows said "Power surge on USB Port", then something about port on USB hub being disabled.
Happened when I ran "sudp apt-get upgrade" and the process got to upgrading "wireshark" - aha!
When I rebooted, and tried the upgrade again, Pi said "dpkg was interrupted, you must manually do 'sudo dpkg --configure -a' to fix the problem..
Seems to be turning into a nigthmare :(
pi@raspberrypi ~ $ sudo apt-get install ssmtp
Reading package lists... Done
Building dependency tree
Reading state information... Done
ssmtp is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
wireshark : Depends: wireshark-common (= 1.8.2-5wheezy13) but 1.8.2-5wheezy11 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
pi@raspberrypi ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
E: Unmet dependencies. Try using -f.
Might be able to recover :
pi@raspberrypi ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
E: Unmet dependencies. Try using -f.
pi@raspberrypi ~ $ sudo apt-get upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages have been kept back:
gir1.2-freedesktop gir1.2-glib-2.0 glib-networking glib-networking-common
glib-networking-services gnome-accessibility-themes gnome-themes-standard
gnome-themes-standard-data libatk1.0-0 libatk1.0-data libgail-3-0 libgcc1
libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgfortran3 libgirepository-1.0-1
libglib2.0-0 libglib2.0-bin libglib2.0-dev libgomp1 libgtk-3-0 libgtk-3-bin
libgtk-3-common libjavascriptcoregtk-3.0-0 libpango1.0-0 librsvg2-2 librsvg2-common
libsoup2.4-1 libstdc++6 libwebkitgtk-3.0-0 php5 php5-cgi php5-common zenity
zenity-common
The following packages will be upgraded:
wireshark wireshark-common wpagui wpasupplicant xdg-utils
5 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2,086 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue [Y/n]?
I found out the hard way when Windows said "Power surge on USB Port", then something about port on USB hub being disabled.
Happened when I ran "sudp apt-get upgrade" and the process got to upgrading "wireshark" - aha!
When I rebooted, and tried the upgrade again, Pi said "dpkg was interrupted, you must manually do 'sudo dpkg --configure -a' to fix the problem..
Seems to be turning into a nigthmare :(
pi@raspberrypi ~ $ sudo apt-get install ssmtp
Reading package lists... Done
Building dependency tree
Reading state information... Done
ssmtp is already the newest version.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
wireshark : Depends: wireshark-common (= 1.8.2-5wheezy13) but 1.8.2-5wheezy11 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
pi@raspberrypi ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
E: Unmet dependencies. Try using -f.
Might be able to recover :
pi@raspberrypi ~ $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
E: Unmet dependencies. Try using -f.
pi@raspberrypi ~ $ sudo apt-get upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages have been kept back:
gir1.2-freedesktop gir1.2-glib-2.0 glib-networking glib-networking-common
glib-networking-services gnome-accessibility-themes gnome-themes-standard
gnome-themes-standard-data libatk1.0-0 libatk1.0-data libgail-3-0 libgcc1
libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgfortran3 libgirepository-1.0-1
libglib2.0-0 libglib2.0-bin libglib2.0-dev libgomp1 libgtk-3-0 libgtk-3-bin
libgtk-3-common libjavascriptcoregtk-3.0-0 libpango1.0-0 librsvg2-2 librsvg2-common
libsoup2.4-1 libstdc++6 libwebkitgtk-3.0-0 php5 php5-cgi php5-common zenity
zenity-common
The following packages will be upgraded:
wireshark wireshark-common wpagui wpasupplicant xdg-utils
5 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2,086 kB of archives.
After this operation, 1,024 B of additional disk space will be used.
Do you want to continue [Y/n]?
Thursday, December 4, 2014
Hit, and.. Miss (Raspberry Pi WiFi)
Trying to get to where I don't have to change my WiFi settings manually each time by changing /etc/network/interfaces at home or xx..
Useless (I tried putting in auto wlan1 and, when I did that, it couldn't even get on the ethernet - had to suffer the humility of connecting monitor and keyboard :( ) :
http://weworkweplay.com/play/automatically-connect-a-raspberry-pi-to-a-wifi-network/
Less useless : (at least the ethernet still worked ) :
http://www.instantsupportsite.com/self-help/raspberry-pi/raspberry-connect-multiple-wireless-networks/
pi@raspberrypi ~ $ sudo ifup wlan0
Line 1: unknown global field 'interface=DIR=/var/run/wpa_supplicant GROUP=netdev'.
Line 1: Invalid configuration line 'interface=DIR=/var/run/wpa_supplicant GROUP=netdev'.
Line 5: failed to parse ssid '”AA″'.
Line 5: failed to parse ssid '”AA″'.
Line 11: Invalid PSK '”XX"'.
Line 11: failed to parse psk '”XX"'.
Line 12: WPA-PSK accepted for key management, but no PSK configured.
Line 12: failed to parse network block.
Line 15: failed to parse ssid '”linksys″'.
Line 15: failed to parse ssid '”linksys″'.
Line 21: Invalid PSK '”CC"'.
Line 21: failed to parse psk '”CC"'.
Line 22: WPA-PSK accepted for key management, but no PSK configured.
Line 22: failed to parse network block.
Failed to read or parse configuration '/etc/wpa_supplicant/wpa_supplicant.conf'.
Failed to bring up wlan0.
Okay, apology - the first line of the .conf should be ctrl_interface=DIR=.. not interface - you know what happened there if you've every used vi :)
And then, OMG, it works!! :
http://raspberrypi.stackexchange.com/questions/11631/wifi-setup-for-multiple-networks
When I do "sudo ifup wlan0" after making the suggested edits, I get :
pi@raspberrypi ~ $ sudo ifup wlan0
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
Would be nice to know what those mean :) But, what a feeling! To be able to type that aaa.homenet.org and login that way!! And, to show you why I believe R-Pi will one day be ubiquitous in evidence collection, here's what I got when I went to aaa.homenet.org/snapshot.jpg (a random shot from when I once went into Heat Sync Labs and plugged the camera in before deciding it was better to work on something more basic. I didn't even know it took a pic!)
Useless (I tried putting in auto wlan1 and, when I did that, it couldn't even get on the ethernet - had to suffer the humility of connecting monitor and keyboard :( ) :
http://weworkweplay.com/play/automatically-connect-a-raspberry-pi-to-a-wifi-network/
Less useless : (at least the ethernet still worked ) :
http://www.instantsupportsite.com/self-help/raspberry-pi/raspberry-connect-multiple-wireless-networks/
pi@raspberrypi ~ $ sudo ifup wlan0
Line 1: unknown global field 'interface=DIR=/var/run/wpa_supplicant GROUP=netdev'.
Line 1: Invalid configuration line 'interface=DIR=/var/run/wpa_supplicant GROUP=netdev'.
Line 5: failed to parse ssid '”AA″'.
Line 5: failed to parse ssid '”AA″'.
Line 11: Invalid PSK '”XX"'.
Line 11: failed to parse psk '”XX"'.
Line 12: WPA-PSK accepted for key management, but no PSK configured.
Line 12: failed to parse network block.
Line 15: failed to parse ssid '”linksys″'.
Line 15: failed to parse ssid '”linksys″'.
Line 21: Invalid PSK '”CC"'.
Line 21: failed to parse psk '”CC"'.
Line 22: WPA-PSK accepted for key management, but no PSK configured.
Line 22: failed to parse network block.
Failed to read or parse configuration '/etc/wpa_supplicant/wpa_supplicant.conf'.
Failed to bring up wlan0.
Okay, apology - the first line of the .conf should be ctrl_interface=DIR=.. not interface - you know what happened there if you've every used vi :)
And then, OMG, it works!! :
http://raspberrypi.stackexchange.com/questions/11631/wifi-setup-for-multiple-networks
When I do "sudo ifup wlan0" after making the suggested edits, I get :
pi@raspberrypi ~ $ sudo ifup wlan0
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
Would be nice to know what those mean :) But, what a feeling! To be able to type that aaa.homenet.org and login that way!! And, to show you why I believe R-Pi will one day be ubiquitous in evidence collection, here's what I got when I went to aaa.homenet.org/snapshot.jpg (a random shot from when I once went into Heat Sync Labs and plugged the camera in before deciding it was better to work on something more basic. I didn't even know it took a pic!)
Wednesday, December 3, 2014
Learns Some at Arduino Night
Arduino wasn't created by Atmel. Arduino was done open source and they happened to use Atmel.
The Large Hadron Collider at CERN runs on Arduino (whatever "run" means in this context)
They've put Arduino in space.
Big thing for me today was Microview. Looks like I can take it, hack it and build the reminder magnet. (Geek Ammo and Cocreators, with manufacturing by Sparkfun - what a success story Sparkfun!)
What does the guy who told me about Arduino in LHC estimate it'll take - about 6 months for a team. You're talking just 80k for the app alone. A lot of people think you can build an app for 2k. You should be prepared to spend at least a 100k on a product mensch sagt. This tiny thing can be 300k - come on man, really? Then what's the point of a PhD in Computational Math?
Arduino Uses Motion Detection to Toggle an LED
=====================================
/*
Assumes a Parallax PIR on pin PIR (11 here) - no pullup resistor needed
http://www.parallax.com/product/28032
*/
int led = 10; // the pin that the LED is attached to
int PIR = 11; // pin that PIR is connected to..
int statePIR;
int prevPIR;
boolean lamp = false;
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
pinMode( PIR, INPUT );
digitalWrite( led, false );
}
// the loop routine runs over and over again forever:
void loop() {
statePIR = digitalRead( PIR );
if( HIGH == statePIR && LOW == prevPIR) {
lamp = !lamp;
}
prevPIR = statePIR;
digitalWrite( led, lamp );
delay( 10);
}
/*
Assumes a Parallax PIR on pin PIR (11 here) - no pullup resistor needed
http://www.parallax.com/product/28032
*/
int led = 10; // the pin that the LED is attached to
int PIR = 11; // pin that PIR is connected to..
int statePIR;
int prevPIR;
boolean lamp = false;
// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
pinMode( PIR, INPUT );
digitalWrite( led, false );
}
// the loop routine runs over and over again forever:
void loop() {
statePIR = digitalRead( PIR );
if( HIGH == statePIR && LOW == prevPIR) {
lamp = !lamp;
}
prevPIR = statePIR;
digitalWrite( led, lamp );
delay( 10);
}
Monday, December 1, 2014
FAQduino : Pin 9 and Pin 13 with Fade
The same OCD that caused me to have time to devote to this means I now start relentlessly improving Arduino.
Now, there's this packaged example called Fade. Why, I mean why can't the people who put it out there have the foresight to see that smart people will wonder why they can't get pin 13 to behave like pin 9.
Any answer? Why can't you change '9' to '13' in the Fade example and get a fade result?
Now, there's this packaged example called Fade. Why, I mean why can't the people who put it out there have the foresight to see that smart people will wonder why they can't get pin 13 to behave like pin 9.
Any answer? Why can't you change '9' to '13' in the Fade example and get a fade result?
Subscribe to:
Posts (Atom)