element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
element14's The Ben Heck Show
  • Challenges & Projects
  • element14 presents
  • element14's The Ben Heck Show
  • More
  • Cancel
element14's The Ben Heck Show
Forum iPod Speaker Dock Idea
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join element14's The Ben Heck Show to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 9 replies
  • Answers 1 answer
  • Subscribers 33 subscribers
  • Views 763 views
  • Users 0 members are here
  • ipod
  • help
  • hack
  • mp3_player_speaker_docks
  • hardware
  • dock
  • build_challenge
  • idea
  • viewer_challenge
  • ben_heck
Related

iPod Speaker Dock Idea

Former Member
Former Member over 12 years ago

I have some speakers I scrapped from a broken LCD TV, and I thought it would be a cool idea to make an iPod dock out of them. I also have a NETduino that i want to implement into this project somehow.

My main problem is the circuitry.

1.) I dont know how to amplify the sound/ what i should use to amplify it

2.) I need to be able to charge the iPod

3.) I want it to get sound from the iPod's dock connector

What i know:

the speakers have 7 ohms of resistance

Any help with this project will be greatly apprecieated

  • Sign in to reply
  • Cancel
Parents
  • shabaz
    0 shabaz over 12 years ago

    Here is some sample C code to play and skip right/left with the old (pre-lightening) dock connector. I have tested this on the original

    iPod touch. It uses the ATmega64, but should be easy to adapt for any processor.

    To use it, call ipod_uart_init() at the start of your program, and then use the ipod_tx_cmd() command whenever you wish to

    control the iPod, e.g. ipod_tx_cmd(PLAY2) etc..

    The '2' is not important, it just means it is a so-called 'type-2' command (the iPod understands some simpler Type-1 commands too, which

    I did not implement.

     

    The instructions are in an array which could be extended for other commands if desired.

     


    // Port E

    // Ipod Rx/Tx pins: (also used as programming port MOSI/MISO)

    #define IPOD_RX 0x01

    #define IPOD_TX 0x02

     

    // ***************** COMMANDS *******************

    #define PLAY2 0

    #define SKIPR2 1

    #define SKIPL2 2

    #define REL2 3


    const unsigned char cmd_arr[]={

      /* mode 2 commands */

      /* play command */

      0x00, 0x00, 0x01,

      /* skip right */

      0x00, 0x08,

      /* skip left */

      0x00, 0x10,

      /* button release */

      0x00, 0x00

    };


    const unsigned int idx_arr[]={

      /* play */

      0,

      /* skip right */

      3,

      /* skip left */

      5,

      /* button release */

      7,

      /* terminate the array */

      9

    };


    // ipod interface (UART0)

    void ipod_uart_init(void)

    {

      // At 14.7Mhz, UBRR0 set to 47 gives 19200baud

      UBRR0H = 0;

      UBRR0L = 47;

      /* Enable receiver and transmitter */

      //UCSR0B = (1<<RXEN0)|(1<<TXEN0);

      UCSR0B = (1<<TXEN0);

      /* Set frame format: 8data, N, 1stop bit */

      UCSR0C = 0x06;

    }


    // This will transmit a single byte across the ipod interface

    void ipod_tx_byte( unsigned char data )

    {

    /* Wait for empty transmit buffer */

    while ( !( UCSR0A & (1<<UDRE0)) )

    ;

    /* Put data into buffer, sends the data */

    UDR0 = data;

    }



    // This will calculate the checksum and transmit all bytes

    void ipod_tx_bytes(unsigned char mode, unsigned char* arr, unsigned char length)

    {

      unsigned int tot;

      unsigned char j;

      unsigned int check;

      unsigned char i;


      tot=length+1+mode;

      for (j=0; j<length; j++)

      {

        tot=tot+arr[j];

      }

      check=0x100-(tot & 0xff);



      ipod_tx_byte(0xff);

      ipod_tx_byte(0x55);

      ipod_tx_byte(length+1);

      ipod_tx_byte(mode);

      for (i=0; i< length; i++)

      {

        ipod_tx_byte(arr[i]);

      }

      ipod_tx_byte((unsigned char)check);

    }


    // This will play a command from the array

    void ipod_tx_cmd(unsigned char cmd)

    {

      int i;

      unsigned int index;

      unsigned char length;


      switch (cmd)

      {

        // Mode 2 commands

        case PLAY2:

        case SKIPR2:

        case SKIPL2:

          index=idx_arr[cmd];

          length=(unsigned char) (idx_arr[cmd+1] - idx_arr[cmd]);

          // transmit these commands a few times in case the ipod misses it

          // (will this ever happen?)

          for (i=0; i<3; i++)

          {

            ipod_tx_bytes(2, (unsigned char*)&cmd_arr[index], length);

          }

          // since it was a mode 2 command, now execute 'button release'

          for (i=0; i<3; i++)

          {

            ipod_tx_bytes(2, (unsigned char*)&cmd_arr[idx_arr[REL2]], idx_arr[REL2 + 1] - idx_arr[REL2] );

          }

          break;

      default:

          break;

      }


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • shabaz
    0 shabaz over 12 years ago

    Here is some sample C code to play and skip right/left with the old (pre-lightening) dock connector. I have tested this on the original

    iPod touch. It uses the ATmega64, but should be easy to adapt for any processor.

    To use it, call ipod_uart_init() at the start of your program, and then use the ipod_tx_cmd() command whenever you wish to

    control the iPod, e.g. ipod_tx_cmd(PLAY2) etc..

    The '2' is not important, it just means it is a so-called 'type-2' command (the iPod understands some simpler Type-1 commands too, which

    I did not implement.

     

    The instructions are in an array which could be extended for other commands if desired.

     


    // Port E

    // Ipod Rx/Tx pins: (also used as programming port MOSI/MISO)

    #define IPOD_RX 0x01

    #define IPOD_TX 0x02

     

    // ***************** COMMANDS *******************

    #define PLAY2 0

    #define SKIPR2 1

    #define SKIPL2 2

    #define REL2 3


    const unsigned char cmd_arr[]={

      /* mode 2 commands */

      /* play command */

      0x00, 0x00, 0x01,

      /* skip right */

      0x00, 0x08,

      /* skip left */

      0x00, 0x10,

      /* button release */

      0x00, 0x00

    };


    const unsigned int idx_arr[]={

      /* play */

      0,

      /* skip right */

      3,

      /* skip left */

      5,

      /* button release */

      7,

      /* terminate the array */

      9

    };


    // ipod interface (UART0)

    void ipod_uart_init(void)

    {

      // At 14.7Mhz, UBRR0 set to 47 gives 19200baud

      UBRR0H = 0;

      UBRR0L = 47;

      /* Enable receiver and transmitter */

      //UCSR0B = (1<<RXEN0)|(1<<TXEN0);

      UCSR0B = (1<<TXEN0);

      /* Set frame format: 8data, N, 1stop bit */

      UCSR0C = 0x06;

    }


    // This will transmit a single byte across the ipod interface

    void ipod_tx_byte( unsigned char data )

    {

    /* Wait for empty transmit buffer */

    while ( !( UCSR0A & (1<<UDRE0)) )

    ;

    /* Put data into buffer, sends the data */

    UDR0 = data;

    }



    // This will calculate the checksum and transmit all bytes

    void ipod_tx_bytes(unsigned char mode, unsigned char* arr, unsigned char length)

    {

      unsigned int tot;

      unsigned char j;

      unsigned int check;

      unsigned char i;


      tot=length+1+mode;

      for (j=0; j<length; j++)

      {

        tot=tot+arr[j];

      }

      check=0x100-(tot & 0xff);



      ipod_tx_byte(0xff);

      ipod_tx_byte(0x55);

      ipod_tx_byte(length+1);

      ipod_tx_byte(mode);

      for (i=0; i< length; i++)

      {

        ipod_tx_byte(arr[i]);

      }

      ipod_tx_byte((unsigned char)check);

    }


    // This will play a command from the array

    void ipod_tx_cmd(unsigned char cmd)

    {

      int i;

      unsigned int index;

      unsigned char length;


      switch (cmd)

      {

        // Mode 2 commands

        case PLAY2:

        case SKIPR2:

        case SKIPL2:

          index=idx_arr[cmd];

          length=(unsigned char) (idx_arr[cmd+1] - idx_arr[cmd]);

          // transmit these commands a few times in case the ipod misses it

          // (will this ever happen?)

          for (i=0; i<3; i++)

          {

            ipod_tx_bytes(2, (unsigned char*)&cmd_arr[index], length);

          }

          // since it was a mode 2 command, now execute 'button release'

          for (i=0; i<3; i++)

          {

            ipod_tx_bytes(2, (unsigned char*)&cmd_arr[idx_arr[REL2]], idx_arr[REL2 + 1] - idx_arr[REL2] );

          }

          break;

      default:

          break;

      }


    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube