5/20/2014

Ubuntu, Raspberry Pi,CubieBoard Linux A2DP, bluetooth audio source receiver service, speaker


Bluetooth A2DP receiver.

$ sudo apt-get install pulseaudio-module-bluetooth
$ pactl load-module module-loopback source_dont_move=yes source=$BTSOURCE sink=$SINK
  • You can find $SINK with $ pactl list sinks, $SINK is shown after Name:
  • And you can see the $BTSOURCE with $ pactl list sources
$ pactl load-module module-loopback source_dont_move=yes source=bluez_source.9C_E6_E7_C8_B2_A3 sink=alsa_output.platform-bcm2835_AUD0.0.analog-stereo
ex) Play audio from Smartphone 

Find pulseaudio source list
 $ pactl list sources
Source #0
        State: IDLE
        Name: alsa_output.platform-bcm2835_AUD0.0.analog-stereo.monitor
        Description: Monitor of bcm2835 ALSA Analog Stereo
        Driver: module-alsa-card.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 4
        Mute: no
        Volume: 0: 100% 1: 100%
                0: 0.00 dB 1: 0.00 dB
                balance 0.00
        Base Volume: 100%
                     0.00 dB
        Monitor of Sink: alsa_output.platform-bcm2835_AUD0.0.analog-stereo
        Latency: 0 usec, configured 371519 usec
        Flags: DECIBEL_VOLUME LATENCY 
        Properties:
                device.description = "Monitor of bcm2835 ALSA Analog Stereo"
                device.class = "monitor"
                alsa.card = "0"
                alsa.card_name = "bcm2835 ALSA"
                alsa.long_card_name = "bcm2835 ALSA"
                alsa.driver_name = "snd_bcm2835"
                device.bus_path = "platform-bcm2835_AUD0.0"
                sysfs.path = "/devices/platform/bcm2835_AUD0.0/sound/card0"
                device.string = "0"
                module-udev-detect.discovered = "1"
                device.icon_name = "audio-card"
        Formats:
                pcm

Source #2
        State: RUNNING
        Name: bluez_source.9C_E6_E7_C8_B2_A3
        Description: SHW-M440S
        Driver: module-bluetooth-device.c
        Sample Specification: s16le 2ch 44100Hz
        Channel Map: front-left,front-right
        Owner Module: 25
        Mute: no
        Volume: 0: 100% 1: 100%
                0: 0.00 dB 1: 0.00 dB
                balance 0.00
        Base Volume: 100%
                     0.00 dB
        Monitor of Sink: n/a
        Latency: 198393 usec, configured 193344 usec
        Flags: HARDWARE DECIBEL_VOLUME LATENCY 
        Properties:
                bluetooth.protocol = "a2dp_source"
                device.description = "SHW-M440S"
                device.string = "9C:E6:E7:C8:B2:A3"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                bluez.path = "/org/bluez/2163/hci0/dev_9C_E6_E7_C8_B2_A3"
                bluez.class = "0x5a020c"
                bluez.name = "SHW-M440S"
                device.icon_name = "audio-card-bluetooth"
        Formats:
                pcm

Arduino pro mini 5v 3.3 v - bootloader, write AVR MKII



Arduino pro mini bootloader write AVR MKII

- Avr Studio 4.18

- Attached avr mkii on Win7 64.

AVR MKII driver install.  ( not libusb driver )


 Your Installed Dir Arduino Sketch \
                            Arduino\
                            arduino-1.5.6-r2-windows\
                            arduino-1.5.6-r2\
                            hardware\
                            arduino\
                            avr\
                            bootloaders


Boot Loader Hex file Pro mini 5V/16MHz

reference from boards.txt ( arduino-1.5.6-r2-windows\arduino-1.5.6-r2\hardware\arduino\avr )

pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex




5/18/2014

OV7670 Pin Map

OV7670 CAMERA 

Arduino ov7670 reference.

http://www.arducam.com/download/

16 pin module.
http://emartee.com/product/41908/

20 pin ? other module.

http://forum.arduino.cc/index.php?PHPSESSID=ltg6b5m1pr6qs956c93k66qc42&topic=159557.0
https://gist.github.com/youngsoonpark/ed893de73026a450b99f
DescriptionNameOV7670 pin
VCC+V1
GroundGND2
SCCB CLKSCL3
SCCB DataSDA4
Vertical synchronizationVSYNC5
Line synchronizationHREF6
FIFO Write EnableWEN7
XCKXCK8
FIFO read address resetRRST9
FIFO chip enableOE10
FIFO read clockRCLK11
GroundGND12
FIFO output dataD013
FIFO output dataD114
FIFO output dataD215
FIFO output dataD316
FIFO output dataD417
FIFO output dataD518
FIFO output dataD619
FIFO output dataD720

5/09/2014

Arduino Mega 2560 pin map


ATmega2560-Arduino Pin Mapping

Below is the pin mapping for the Atmega2560. The chip used in Arduino 2560. There are pin mappings to Atmega8 and Atmega 168/328 as well.

Arduino Mega 2560 PIN diagram


The source SVG file is also available for download: PinMapping2560.zip

Arduino Mega 2560 PIN mapping table

Pin NumberPin NameMapped Pin Name
1PG5 ( OC0B )Digital pin 4 (PWM)
2PE0 ( RXD0/PCINT8 )Digital pin 0 (RX0)
3PE1 ( TXD0 )Digital pin 1 (TX0)
4PE2 ( XCK0/AIN0 ) 
5PE3 ( OC3A/AIN1 )Digital pin 5 (PWM)
6PE4 ( OC3B/INT4 )Digital pin 2 (PWM)
7PE5 ( OC3C/INT5 )Digital pin 3 (PWM)
8PE6 ( T3/INT6 ) 
9PE7 ( CLKO/ICP3/INT7 ) 
10VCCVCC
11GNDGND
12PH0 ( RXD2 )Digital pin 17 (RX2)
13PH1 ( TXD2 )Digital pin 16 (TX2)
14PH2 ( XCK2 ) 
15PH3 ( OC4A )Digital pin 6 (PWM)
16PH4 ( OC4B )Digital pin 7 (PWM)
17PH5 ( OC4C )Digital pin 8 (PWM)
18PH6 ( OC2B )Digital pin 9 (PWM)
19PB0 ( SS/PCINT0 )Digital pin 53 (SS)
20PB1 ( SCK/PCINT1 )Digital pin 52 (SCK)
21PB2 ( MOSI/PCINT2 )Digital pin 51 (MOSI)
22PB3 ( MISO/PCINT3 )Digital pin 50 (MISO)
23PB4 ( OC2A/PCINT4 )Digital pin 10 (PWM)
24PB5 ( OC1A/PCINT5 )Digital pin 11 (PWM)
25PB6 ( OC1B/PCINT6 )Digital pin 12 (PWM)
26PB7 ( OC0A/OC1C/PCINT7 )Digital pin 13 (PWM)
27PH7 ( T4 ) 
28PG3 ( TOSC2 ) 
29PG4 ( TOSC1 ) 
30RESETRESET
31VCCVCC
32GNDGND
33XTAL2XTAL2
34XTAL1XTAL1
35PL0 ( ICP4 )Digital pin 49
36PL1 ( ICP5 )Digital pin 48
37PL2 ( T5 )Digital pin 47
38PL3 ( OC5A )Digital pin 46 (PWM)
39PL4 ( OC5B )Digital pin 45 (PWM)
40PL5 ( OC5C )Digital pin 44 (PWM)
41PL6Digital pin 43
42PL7Digital pin 42
43PD0 ( SCL/INT0 )Digital pin 21 (SCL)
44PD1 ( SDA/INT1 )Digital pin 20 (SDA)
45PD2 ( RXDI/INT2 )Digital pin 19 (RX1)
46PD3 ( TXD1/INT3 )Digital pin 18 (TX1)
47PD4 ( ICP1 ) 
48PD5 ( XCK1 ) 
49PD6 ( T1 ) 
50PD7 ( T0 )Digital pin 38
51PG0 ( WR )Digital pin 41
52PG1 ( RD )Digital pin 40
53PC0 ( A8 )Digital pin 37
54PC1 ( A9 )Digital pin 36
55PC2 ( A10 )Digital pin 35
56PC3 ( A11 )Digital pin 34
57PC4 ( A12 )Digital pin 33
58PC5 ( A13 )Digital pin 32
59PC6 ( A14 )Digital pin 31
60PC7 ( A15 )Digital pin 30
61VCCVCC
62GNDGND
63PJ0 ( RXD3/PCINT9 )Digital pin 15 (RX3)
64PJ1 ( TXD3/PCINT10 )Digital pin 14 (TX3)
65PJ2 ( XCK3/PCINT11 ) 
66PJ3 ( PCINT12 ) 
67PJ4 ( PCINT13 ) 
68PJ5 ( PCINT14 ) 
69PJ6 ( PCINT 15 ) 
70PG2 ( ALE )Digital pin 39
71PA7 ( AD7 )Digital pin 29
72PA6 ( AD6 )Digital pin 28
73PA5 ( AD5 )Digital pin 27
74PA4 ( AD4 )Digital pin 26
75PA3 ( AD3 )Digital pin 25
76PA2 ( AD2 )Digital pin 24
77PA1 ( AD1 )Digital pin 23
78PA0 ( AD0 )Digital pin 22
79PJ7 
80VCCVCC
81GNDGND
82PK7 ( ADC15/PCINT23 )Analog pin 15
83PK6 ( ADC14/PCINT22 )Analog pin 14
84PK5 ( ADC13/PCINT21 )Analog pin 13
85PK4 ( ADC12/PCINT20 )Analog pin 12
86PK3 ( ADC11/PCINT19 )Analog pin 11
87PK2 ( ADC10/PCINT18 )Analog pin 10
88PK1 ( ADC9/PCINT17 )Analog pin 9
89PK0 ( ADC8/PCINT16 )Analog pin 8
90PF7 ( ADC7 )Analog pin 7
91PF6 ( ADC6 )Analog pin 6
92PF5 ( ADC5/TMS )Analog pin 5
93PF4 ( ADC4/TMK )Analog pin 4
94PF3 ( ADC3 )Analog pin 3
95PF2 ( ADC2 )Analog pin 2
96PF1 ( ADC1 )Analog pin 1
97PF0 ( ADC0 )Analog pin 0
98AREFAnalog Reference
99GNDGND
100

5/07/2014

rfcomm server example c linux

$ gcc rfcomm-server.c -lbluetooth
$ ./a.out


#include
#include
#include
#include
#include

int main(int argc, char **argv)
{
    struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
    char buf[1024] = { 0 };
    int s, client, bytes_read;
    socklen_t opt = sizeof(rem_addr);

    // allocate socket
    s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

    // bind socket to port 1 of the first available
    // local bluetooth adapter
    loc_addr.rc_family = AF_BLUETOOTH;
    loc_addr.rc_bdaddr = *BDADDR_ANY;
    loc_addr.rc_channel = (uint8_t) 15;
    bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr));

    // put socket into listening mode
    listen(s, 1);
    client=0;    // initialize connection handle.
    while(1)
    {  
            if( client == 0 )
            {
            // accept one connection
            printf("accept wait\n");
            client = accept(s, (struct sockaddr *)&rem_addr, &opt);
            printf("now accept %d\n",client);
 
            ba2str( &rem_addr.rc_bdaddr, buf );
            fprintf(stderr, "accepted connection from %s\n", buf);
            memset(buf, 0, sizeof(buf));
            }
 
            // read data from the client
            bytes_read = read(client, buf, sizeof(buf));
            if( bytes_read > 0 )
            {
                printf("received [%s]\n", buf);
            }
            else
            if( bytes_read < 0 )
            {
                close(client);
                client=0;
                printf("close connection\n");
            }
            printf("bytes_read [%d]\n",bytes_read);
    }

    // close connection
    close(client);
    close(s);
    return 0;
}