Thread: How to send 4 bit data

  1. #1
    Registered User
    Join Date
    Oct 2019
    Posts
    68

    How to send 4 bit data

    Hi

    assume I have 8 bit string and I want to send higher nibble to LCD then want to send lower nibble bit to LCD

    Code:
    #include<stdio.h>
    
    void main (){
    	
    	unsigned char buffer[8]= {"12345678"}; // MSB to LSB 
    	//first call -> send higer nibble 1234
    	//second call -> send lower nibble 5678
    }
    
    
    void send ( unsigned  char *pointer) {
    	
    }
    any help would be appreciated.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,682
    Something like
    Code:
    for ( i = 0 ; i < 8 ; i++ ) {
      send(buffer[i] & 0xF);  // lower 4 bits
      send((buffer[i]>>4) & 0xF);  // upper 4 bits
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Location
    Namib desert
    Posts
    91
    You wrote: "I have 8 bit string and I want...."
    Just for the record; your "unsigned char buffer[8]" is an array of 8 bytes and it is not 0-terminated so it is not a C-string...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to send message(data) from c to c#?
    By smahdi1991 in forum C# Programming
    Replies: 2
    Last Post: 03-25-2014, 11:34 AM
  2. Send data to a resource?
    By Anddos in forum Windows Programming
    Replies: 1
    Last Post: 03-14-2012, 11:23 PM
  3. Send data with class
    By Ducky in forum Networking/Device Communication
    Replies: 6
    Last Post: 08-08-2009, 09:16 AM
  4. recieve data, then send data to all other clients
    By b00l34n in forum Networking/Device Communication
    Replies: 6
    Last Post: 07-25-2004, 11:13 AM
  5. Trying to send data over a network
    By CyberVulpine in forum C++ Programming
    Replies: 1
    Last Post: 06-06-2002, 11:45 AM

Tags for this Thread