Go Down

Topic: SlugRadio: Arduino controls NSLU2-based internet radio player (Read 5057 times) previous topic - next topic

Schwabinger

Since today my SlugRadio has even a display, that shows the station, that is just playing.

See the latest photos and a little movie here:

http://arduino.cc/forum/index.php/topic,8827.0.html

New features:

Station lock:
========

in the meantime I have 35 stations on my list. So it happens from time to time that it toggles between two stations; the more stations I will add, the more often this problem will occur.

So I implemented a button that sets a station lock. As soon as the button is pressed, the tuner value that is sent to the slug, cannot change any more.

Code: [Select]
// Switch between normal and freeze mode:

buttonFreezeState = digitalRead(FreezeButtonPin);

switch(programState) {
  case NonFreezeMode:
  if (buttonFreezeState == HIGH) {
     digitalWrite(FreezeLedPin, HIGH);
    programState = FreezeMode; }
  break;
case FreezeMode:
  if (buttonFreezeState == HIGH) {
     digitalWrite(FreezeLedPin, LOW);
    programState = NonFreezeMode;
  }
  break;

  default:
  programState = NonFreezeMode;
  break;
}

..


if (programState == NonFreezeMode) {
  tunerValue = map(sensorValue, 0, 1023, 1, numbStations);
}




Podcasts on the slug
=================
In addition I made use of the ability of "podcast-bounce" (see above) to play modcasts with mpd / mpc.
Padcast stations are added to the playlist in this format:

Code: [Select]
    mpc add http://linksys:8082/?feed=http://www.br-online.de/podcast/b5-fuer-bergsteiger/cast.xml # P: B5 Bergsteiger
    mpc add http://linksys:8082/?feed=http://www.br-online.de/podcast/funkstreifzug/cast.xml # P: B5 Funkstreifzug



Schwabinger

Schwabinger

Programmable station button
=========================
SlugRadio has a station button now; you can use it to save your favorite station. Pressing the botton saves it's numerical value in EEPROM.


SlugRadio by RigasW, on Flickr

As long as you are in NonStationKeyMode, tuning is done using the pot.
When you press the station Botton, turning the pot does not change the station any more; instead, the saved station number from eeprom is sent to the slug.

Here is part of the code:

Code: [Select]
buttonState = digitalRead(buttonPin);

switch(StationKeyState) {

  case NonStationKeyMode:
  // write current station value in EEPROM
  if (buttonState == HIGH & programState == FreezeMode) {
   digitalWrite(ledPin, HIGH);
   delay(300);
   digitalWrite(ledPin, LOW);
   EEPROM.write(0, tunerValue);
   
}
   if (buttonState == HIGH) {
   // read station value from EEPROM postion 0.
   tunerValue = EEPROM.read(0);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);

  }
   break;

case StationKeyMode:
  if (buttonState == HIGH) {
     StationKeyState = NonStationKeyMode;
     digitalWrite(ledPin, LOW);
  }
     break;
 
   
  default:
  programState = NonStationKeyMode;
  break;
}


Next I will try to built a shiftIN register for handling 8 buttons.


Schwabinger

Schwabinger

Pushbutton for favourite stations
============================

Turning the station dial is lots of fun, but I wanted to have fast access to some favourite stations ... so I added some push-buttons.


8 Pushbottons by RigasW, on Flickr


I used a shiftIn registered as described in the tutorial here in arduino.cc to address the buttons.

If you want to save a station number to a button, you have to do the following:

- Select the sation by turning the tuning dial.
- Go into freeze mode
- Press the button, that you want to use for that station
- The station number is written in eeprom
- Exit freeze mode.

If you now press the station button, SlugRadio switches to the saved station. In addition, a led lights up, indicating, that you are listening to a programmed station.

Here is part of the code:

Code: [Select]
buttonState = digitalRead(buttonPin);

switch(StationKeyState) {

  case NonStationKeyMode:

  // you have to be in freeze mode;  then pressing the station button will save the station value im eeprom.
   
   if (((switchVar1 & B10000000) == B10000000) & programState == FreezeMode) {
   digitalWrite(ledPin, HIGH);
   delay(300);
   digitalWrite(ledPin, LOW);
   EEPROM.write(1, tunerValue);
   }
   
   if (((switchVar1 & B00000100) == B00000100) & programState == FreezeMode){
      digitalWrite(ledPin, HIGH);
      delay(300);
      digitalWrite(ledPin, LOW);
      EEPROM.write(2, tunerValue);
   }
     
    if (((switchVar1 & B00000010) == B00000010) & programState == FreezeMode){
      digitalWrite(ledPin, HIGH);
      delay(300);
      digitalWrite(ledPin, LOW);
      EEPROM.write(3, tunerValue);
   }
   
      if (((switchVar1 & B00001000) == B00001000) & programState == FreezeMode){
      digitalWrite(ledPin, HIGH);
      delay(300);
      digitalWrite(ledPin, LOW);
      EEPROM.write(4, tunerValue);
   }
   
   
   if (((switchVar1 & B00000001) == B00000001) & programState == FreezeMode){
      digitalWrite(ledPin, HIGH);
      delay(300);
      digitalWrite(ledPin, LOW);
      EEPROM.write(5, tunerValue);
   }
   
     if (((switchVar1 & B00010000) == B00010000) & programState == FreezeMode){
      digitalWrite(ledPin, HIGH);
      delay(300);
      digitalWrite(ledPin, LOW);
      EEPROM.write(6, tunerValue);
   }
   
   
   // pressing the station botton in regular operation will get the station value from eeprom.
   
 
if ((switchVar1 & B10000000) == B10000000){
   tunerValue = EEPROM.read(1);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }

if ((switchVar1 & B00000100) == B00000100){   
   tunerValue = EEPROM.read(2);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }
   
    if ((switchVar1 & B00000010) == B00000010){   
   tunerValue = EEPROM.read(3);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }
 
    if ((switchVar1 & B00001000) == B00001000){   
   tunerValue = EEPROM.read(4);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }
   
   
       if ((switchVar1 & B00000001) == B00000001){   
   tunerValue = EEPROM.read(5);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }
 
     if ((switchVar1 & B00010000) == B00010000){   
   tunerValue = EEPROM.read(6);
   StationKeyState = StationKeyMode;
    digitalWrite(ledPin, HIGH);
  }
   
   break;

case StationKeyMode

if ((switchVar1 & B10000000) == B10000000){ 
  StationKeyState = NonStationKeyMode;
     digitalWrite(ledPin, LOW);
  }
 
   if ((switchVar1 & B00000100) == B00000100){   
      StationKeyState = NonStationKeyMode;
      digitalWrite(ledPin, LOW);
  }
 
   if ((switchVar1 & B00000010) == B00000010){   
      StationKeyState = NonStationKeyMode;
      digitalWrite(ledPin, LOW);
  }


   if ((switchVar1 & B00001000) == B00001000){   
      StationKeyState = NonStationKeyMode;
      digitalWrite(ledPin, LOW);
  }

   if ((switchVar1 & B00000001) == B00000001){   
      StationKeyState = NonStationKeyMode;
      digitalWrite(ledPin, LOW);
  }


if ((switchVar1 & B00010000) == B00010000){   
      StationKeyState = NonStationKeyMode;
      digitalWrite(ledPin, LOW);
  }
 
     break;
     
  default:
  programState = NonStationKeyMode;
  break;
}


Enjoy!

Schwabinger






majk2000

Is it possible to run internet radio on Arduino without Linux? If yes, are there software libraries for it somewhere? Where? Thanks

daveg360

Nice project - love the case  8)

In answer to the above  - not in a million years.

Go Up