Showing posts with label LINUX. Show all posts
Showing posts with label LINUX. Show all posts

Monday, October 14, 2013

Sainsmart 8 Channel Relay

I recently purchased a Sainsmart 8 channel relay for use with some holiday lighting with my Arduino, I had some sketches already typed up for use with another project however I soon discovered that the relay board does not simply turn off with the normal LOW command with the digital output pins.I basically spent half a day writing up a new sketch and trying it until I got it to perform the way that I wanted it to. I have an ITEAD Mp3 shield I am using with it, so I cant guarantee this sketch will work for anyone else, But it’s a starting point since I found hardly any information on this relay board.This page is the best information I found but it only loops the relays so I had to us his example to formulate the code to do as I wished.If you look at your serial output and adjust the sense limit and smoothing you can get it to react to some some degree to the music.

IMG_0033[1]

 

// Sainsmart 8 channel relay v1.0
//



#define NUMREADINGS 70 // raise this number to increase data smoothing

int senseLimit = 400; // raise this number to decrease sensitivity (up to 1023 max)
int probePin = 3; // analog 3
int val = 0; // This is the reading from the probePin

#define RELAY_ON 1
#define RELAY_OFF 0

#define Relay_1 4 // Arduino Digital I/O pin number
#define Relay_2 5
#define Relay_3 6
#define Relay_4 7
#define Relay_5 8
#define Relay_6 9
#define Relay_7 10
#define Relay_8 11


// variables for smoothing

int readings[NUMREADINGS]; // the readings from the current analog input
int index = 0; // the index of the current reading
int total = 8; // the running total (Realys)
int average =0; // final average of the probe reading


void setup() {


pinMode(Relay_8, OUTPUT); // specify Relay Outputs
pinMode(Relay_7, OUTPUT);
pinMode(Relay_6, OUTPUT);
pinMode(Relay_5, OUTPUT);
pinMode(Relay_4, OUTPUT);
pinMode(Relay_3, OUTPUT);
pinMode(Relay_2, OUTPUT);
pinMode(Relay_1, OUTPUT);

Serial.begin(9600); // initiate serial connection for debugging/etc

for (int i = 0; i < NUMREADINGS; i++)
readings[i] = 0; // initialize all the readings to 0
}

void loop() {

val = analogRead(probePin); // take a reading from the probe

if(val >= 1){ // if the reading isn't zero, proceed

val = constrain(val, 1, senseLimit); // turn any reading higher than the senseLimit value into the senseLimit value
val = map(val, 1, senseLimit, 1, 1023); // remap the constrained value within a 1 to 1023 range

total -= readings[index]; // subtract the last reading
readings[index] = val; // read from the sensor
total += readings[index]; // add the reading to the total
index = (index + 1); // advance to the next index

if (index >= NUMREADINGS) // if we're at the end of the array...
index = 0; // ...wrap around to the beginning

average = total / NUMREADINGS; // calculate the average


if (average > 250){ // if the average is over 250 ...
digitalWrite(Relay_1, RELAY_ON); // Turn on the first Relay*
}
else{ // and if it's not ...
digitalWrite(Relay_1, RELAY_OFF); // turn that Relay off
}

if (average > 300){ // and so on ...
digitalWrite(Relay_2, RELAY_ON);
}
else{
digitalWrite(Relay_2, RELAY_OFF);
}

if (average > 350){
digitalWrite(Relay_3, RELAY_ON);
}
else{
digitalWrite(Relay_3, RELAY_OFF);
}

if (average > 375){
digitalWrite(Relay_4, RELAY_ON);
}
else{
digitalWrite(Relay_4, RELAY_OFF);
}

if (average > 400){
digitalWrite(Relay_5, RELAY_ON);
}
else{
digitalWrite(Relay_5, RELAY_OFF);
}

if (average > 450){
digitalWrite(Relay_6, RELAY_ON);
}
else{
digitalWrite(Relay_6, RELAY_OFF);
}

if (average > 550){
digitalWrite(Relay_7, RELAY_ON);
}
else{
digitalWrite(Relay_7, RELAY_OFF);
}

if (average > 600){
digitalWrite(Relay_8, RELAY_ON);
}
else{
digitalWrite(Relay_8, RELAY_OFF);
}


Serial.println(val); // use this output to aid in calibrating
}
}

Tuesday, February 8, 2011

How to Change Audio Formats

To answer a question I was asked, How to change a file to MP3 I will assume an OGG. The program I have had the best luck with that I have installed is SoundConverter.


I know there are faster ways to do it {ffmpeg -i example.ogg to example.mp3}
from the command line but I wrote this  for the less experienced. also if you are doing a whole folder Sound converter might be the better choice.

Saturday, December 18, 2010

3gp Video Coversion

I recently was in need of converting a video to 3GP format so I was able to play it on my HTC tp, Now there are a lot of programs for doing this in a windows environment and I even have one however I wanted to find a way to do it running Ubuntu. I was able to do it with Pitivi This program actually does a whole lot and I was very impressed with it. I was able to load it from Synaptic package manager.





This video is all ready in 3GP format but I only loaded it for representation.

Saturday, May 29, 2010

NAS Server

I found a new program Freenas based upon free BSD that allows you to use an old computer for network storage. It uses hardly any resources you can set it up as a headless server and hide it away in a corner someplace. It took very little time to set it up and get it on line. I have a lot of old hardware sitting around and was going to get another portable hard drive so I thought I would try this and save myself some money. So far so good the firewall seems simple enough as well.This is the web interface to set it up from another computer.



Saturday, April 17, 2010

Windows In Mandriva


Here is a screen shot of Windows 7 running in virtual box on my Mandriva machine, I wanted to see how it performs on this system I dual boot with XP. I have a Dell laptop with windows 7 on it and I am pleased with it, as much as I dislike Windows I still need it for certain work related things. As for my every day needs I use Mandriva.

Sunday, March 7, 2010

Lightscribe & Linux

while I was using Ubuntu I was able to get lightscribe working properly however with Mandriva I could only get the simple label maker to work
I found this Fedora help page that solved my problem so I now have the Image printing Lightscribe as well.

After all the pages I have had to visit to find this information I hope it helps someone else who has similar problem. The only thing the Linux version is lacking is a quick tab in the program to add the tracks from the cd or dvd.I know the Nero software that came with my drive has this feature but I would rather go without than have to depend on Windows for that one feature.

Saturday, January 23, 2010

Video Card

I bought a new video card this week since my other was lacking performance in the gaming dept. I have been playing Call of Duty and Timeshift. I really like Timeshift it is one of the better games I have played.

The card I got got works very well with Linux It detected it on boot up and everything has worked without a hitch.

Sunday, December 27, 2009

Mandriva 2010 gcc

I loaded Mandriva 2010 on a computer today and when I went to do an install from a command line I was told I didn't have a c compiler.
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
[root@localhost linuxwacom-0.8.5-8]

Needless to say the GUI software installer refused to load any GCC C++ compiler listed. so use this
urpmi gcc-c++
and now you can actually use the terminal, I have no idea why they would leave this out?
Other than that I love Mandriva 2010 it has everything I use loaded all ready so it just plain worked from the get go.

Wednesday, December 23, 2009

Tweak UBUNTU

I use Ubuntu on my main computer and recently found this program to tweak Ubuntu.

It works very good and has a lot of options that a newbie would have to hunt around for.Here is the download site. It is designed for the GNOME desktop environment so KUBUNTU users will have to still do things the old fashioned way. Be sure you back anything up that is important to you before you use this the first time as well since there are some options that could allow you to change important settings. It does make you enter the root password and give you warnings before entering areas that allow changing important settings. There is a large list of 3rd party software available that saves a lot of time on a fresh install.

Sunday, December 13, 2009

Epson Printers & Scanners

I have an Epson all in one printer scanner, I have used it with Ubuntu before and I remember I had a hard time ever getting the scanner to work right with Xsane. Today I happened to be reading something on a message board "not even sure what one now" but I opened a link telling about Drivers for Epson printers so I  looked and low and behold there was my scanner listed. I had never hooked it back up to my linux system since my last Upgrade to Karmic Koala. So I hooked it up and downloaded the driver specified for my model it said a dependency wasn't met so I made a quick stop by here and downloaded the missing file.  I was surprised to see that everything worked as it should and much better than it did the one other time I had it hooked up on here. Thats one less reason to keep that one computer of mine running Windows! It just kind of sits there now until someone needs to do something that requires a Windows environment. Thats not very often anymore, Both my boys use Ubuntu on their computers as well as me.

Tuesday, November 17, 2009

Mouse

I am going to have to get me one of these considering I have a dollar store mouse thats about 4 years old but hey it works just time to upgrade and to me this mouse would be no less than state of the art.



CNET gave it a good review so I am thinking its probably worth the money I just hope it lasts as long as my dollar store mouse.Oh yes it is a Microsoft mouse but I don't have a problem with Microsoft hardware just their software. the best part is any Microsoft hardware I have used has usually worked on Linux with out a hitch. It just doesn't always work right running under Windows.

Gimp






I was bored and started messing around with Gimp, every time I do I find more useful things I can do with this program. You can really alter an image with this powerful program and even make your own images from scratch.

Sunday, November 15, 2009

Compiz Fusion Icon

Today I found that there is an Icon for Compiz Fusion for the taskbar, It integrates your desktop managers and other settings into one place to quickly change things.




To install it in Ubuntu open a terminal and insert this code
 
sudo apt-get install fusion-icon
 

Thats it, I like it because its simple and I dont have to open 3 other windows to change settings. I hope someone else finds this useful as I did.

Monday, November 9, 2009

Compiz

Compiz works excellent with the newest Ubuntu. I remember a few years ago how complicated and hit or miss it used to be setting it up and to tweak it just the way you wanted it. Now it just works plain and simple. Maybe someday Microsoft will get the picture that writing proprietary code is senseless, with proprietary code you must write new code for every new piece of hardware whereas open source allows you to build on code thats all ready written. Open source also allows anyone to alter and redistribute the software, so basically open source is written the way USERS want it not the way software vendors want it. Look at Vista for example yup pretty but doesn't work so good, you can put lipstick on a pig but its still a pig underneath. GNU




Tuesday, November 3, 2009

Ubuntu Karmic Koala

Ok last night I was having issues with my system after updating my Ubuntu, well it seems there was a possible compatibility issue with my system after the update. It seems firefox was not playing nice with the flash player and this morning It crashed and I was forced to do a clean install. I suppose it was for the better since I have noticed everything seems ok now and actually see some differences I had not seen after the upgrade. I never did find out what exactly caused the system to crash except reference to a theme I had installed panicked. All in all it is a lot better in my opinion. I am using Opera web browser for a lot of things though just until I am sure i have all the bugs worked out.

Monday, October 26, 2009

Widgets

Here is a really useful widget for Superkaramba called Automatik . I personally like it because it works very well with dual core cpu's and I didn't have to install anything extra on Ubuntu to get it to work, as long as you have sensors and KDE installed. I like to play around with all the different Themes and stuff on KDE look.





Friday, August 14, 2009

Terminal Screensaver


This is How to make a screen saver in UBUNTU that looks like a running terminal program the easy way.

First of all you want to make sure you have Xscreensaver-data and Xscreensaver-data-extra.

If not you can simply paste this code in a terminal. Or go to synaptic package manager.


----------------------------------------------------------

Sudo apt-get install xscreensaver-data


sudo apt-get install xscreensaver-data-extra

----------------------------------------------------------

Now you will want to go to the menu bar and select (system,preferences,screen saver) now select Phosphor if you go to advanced you will see you can choose a simple text file to use for your scrolling text to simulate a terminal program running. I just made my own with my text editor and saved it as a text file. Any type of text will work so you can pretty much customise it any way you wish.Good luck and enjoy.




Tuesday, July 28, 2009

XFX 8200

I built a computer for someone back a few months ago with an XFX Geforce 8200 motherboard and a Phenom x4 cpu, at first everything was fine but after a few weeks it began acting up. It even fragged the Linux kernal on one install, it had multiple problems listed in the logs most of which led to the cpu.After giving it some thought I got a new Asus motherboard identicle to mine I use every day and bought an Athlon 64 X2 7550 cpu. I swapped the motherboard out and put the XFX one with the new cpu in my second computer I use for my personal weather station and stuff because I wanted to get to the bottom of the problem, Well its been about 3 weeks and so far I have had no problems at all with it. The CPU I put in it is a screamer it has the KUMA core and 3 MB cache. I even overclocked it some to try and get it do do something but so far its been running fine and I even like the motherboard and its features. I also put 2 GB of the OCZ SLI memory in it and that even works like a charm. After not finding anything wrong with my new setup I decided to just keep it and see how things go. That left me with a pile of spare parts laying about so I built a Frankenputer with all of it and handed it off to my youngest son.

Saturday, June 27, 2009

Fading Windows

Here is a screen shot of the fading windows with compiz animations enabled, There are several different types of fades you can choose to display or not display. I choose the random output so they are different each time I open or close something.

Friday, June 26, 2009

Compiz


This is one reason why I love LINUX over Windows hands down, I remember when compiz was first launched and was buggy and had to played with to get it just right, now it just plain works.