Non classé

Dernière mise à jour le 25/03/16

Présentation


Le programme ci-dessous, permet de déplacer n’importe quel fichier dans un dossier. Bien sûr afin que ce fichier soit déplacer il faut modifier les lignes de code proposé ci-dessous

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; 
using System.Threading; 
using System.IO; //activer le système IO
using System.IO.Compression; // Ben activer la référence "System.IO.Compression.FileSystem"

namespace Deplacement_fichier_vers_dossier
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sourceFile = @"C:\Users\Benjamin\Desktop\Classeur1.xlsm"; // ficher excel "Classuer1.xlsm"  à déplacer 
            string destinationFile = @"C:\Users\Benjamin\Desktop\test\Classeur1.xlsm"; // fichier mis dans le dossier "test" désiré

            // To move a file or folder to a new location:
            System.IO.File.Move(sourceFile, destinationFile); // procédure qui permet de déplacer le fichier Excel dans le dossier "test" 

        }
    }
}

Historiques


25/03/16
– Première mise à disposition

Dernière mise à jour le 19/03/16

Présentation


La programmation qui va suivre est une amélioration de Simulation touches clavier 001 .La programmation est basé sur la Dll (« user32.dll »).

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices; // on active le Runtime
using System.Threading; // permet d'utiliser le Thread.Sleep(ms)
using System.Diagnostics; // on active pour permettre d'utiliser la fonction Process.Start pour ouvrir application

namespace Touches_Clavier_002
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
        }
        

        private void BlocNote_Click(object sender, EventArgs e)
        {
            Process.Start(@"C:\Users\Julien\Desktop\test.txt"); // on ouvre le bloc note 
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("Bienvenue à tous sur mon site Electronique71.com"); // écriture dans le bloc note
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("{ENTER}"); // simule touche ENTRER
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("^{a}"); // simule touche CTRL a
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("^{c}"); // simule touche CTRL c
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("{ENTER}"); 
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("{ENTER}");
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("{ENTER}");
            Thread.Sleep(1000); // 1 secs après
            SendKeys.Send("^{v}"); // simule CTRL v
        } 
    }
}

Dernière mise à jour le 19/03/16

Présentation


La programmation qui va suivre permet de simuler quelque touches du clavier azerty. La programmation est basé sur la Dll (« user32.dll »).

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices; // on active le Runtime
using System.Threading; // permet d'utiliser le Thread.Sleep(ms)
using System.Diagnostics; // on active pour permettre d'utiliser la fonction Process.Start pour ouvrir application 

namespace Touches_Clavier_001
{
    public partial class Form1 : Form
    {

        const int KEYEVENTF_KEYUP = 0x0002; //Evenement du relachement de la touche active
        const int VK_CONTROL = 0x11; //simuler touche CTRL
        const int VK_SHIFT = 0x10; // simuler touche SHIFT
        const int VK_RETURN = 0x0D; // simuler touche ENTRER
        const int J = 0x4A; //code de la touche J

        [DllImport("user32.dll", SetLastError = true)]
        static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);


        public Form1()
        {
            InitializeComponent();
        }
        

        private void BlocNote_Click(object sender, EventArgs e)
        {
            Process.Start(@"C:\Users\Julien\Desktop\test.txt"); //  on ouvre le bloc note situé sur le bureau
            Thread.Sleep(5000); // 5 secs après
            SendKeys.Send("Bienvenue à tous sur mon site DJelectro71.com"); // écriture dans le bloc note
            Thread.Sleep(5000); // 5 secs après
            // Ci-dessous écriture de "J" et "j"
            keybd_event(VK_RETURN, 0, 0, 0); // On active la touche ENTRER du clavier
            Thread.Sleep(1000); // 1 sec après
            keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0); // On relache la touche ENTRER du clavier
            keybd_event(VK_SHIFT, 0, 0, 0); // On active la touche SHIFT du clavier
            Thread.Sleep(1000); // 1 sec après
            keybd_event(J, 0, 0, 0); // On active la touche "J"
            keybd_event(VK_SHIFT, J, KEYEVENTF_KEYUP, 0); // On relache la touche SHIFT et la touche J
            keybd_event(J, 0, 0, 0); // On active la touche "j" de nouveau
            Thread.Sleep(5000); // 5 secs après 
            keybd_event(0, J, KEYEVENTF_KEYUP, 0); // On relache la touche "j"
 
        } 
    }
}

Dernière mise à jour le 19/03/16

Présentation


Clic_Souris_001

La programmation qui va suivre permet de simuler un clic gauche, ainsi que le clic droit. Vous pouvez récupérer ce petite programme à condition que vous ayez le Framework.Net d’installer sur votre ordinateur. Je vous laisse vous joindre sur ce lien Logiciels . La programmation est basé sur la Dll (“user32.dll”), et nous verrons avec le programme ci-dessous ce que C# peut faire par simulation.

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices; // on active le Runtime
using System.Threading; // permet d'utiliser le Thread.Sleep(ms)

namespace Clic_Souris_001
{
    public partial class Form1 : Form
    {
        const uint MOUSEEVENTF_ABSOLUTE = 0x8000;
        const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
        const uint MOUSEEVENTF_LEFTUP = 0x0004;
        const uint MOUSEEVENTF_MIDDLEDOWN = 0x0020;
        const uint MOUSEEVENTF_MIDDLEUP = 0x0040;
        const uint MOUSEEVENTF_MOVE = 0x0001;
        const uint MOUSEEVENTF_RIGHTDOWN = 0x0008;
        const uint MOUSEEVENTF_RIGHTUP = 0x0010;
        const uint MOUSEEVENTF_XDOWN = 0x0080;
        const uint MOUSEEVENTF_XUP = 0x0100;
        const uint MOUSEEVENTF_WHEEL = 0x0800;
        const uint MOUSEEVENTF_HWHEEL = 0x01000;

        [DllImport("user32.dll")]
        private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);

        public Form1()
        {
            InitializeComponent();
        }

        private void Gauche_Click(object sender, EventArgs e)
        {
            Thread.Sleep(5000); //dans 5 sec le clic
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); // On simule le bouton gauche enfoncé
            Thread.Sleep(100); // 100 ms après
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // On simule le relâchement du bouton gauche
        }

        private void Droit_Click(object sender, EventArgs e)
        {
            Thread.Sleep(5000); //dans 5 sec le clic
            mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); // On simule le bouton droit enfoncé
            Thread.Sleep(100); // 100 ms après
            mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); // On simule le relâchement du bouton droit
        }
    }
}

Test avec le fichier (.exe) à télécharger Simulation clic souris

dernière mise à jour le 03/04/16

Présentation


Ce nouveau montage permet d’écrire via un clavier raccorder sur le port USB d’écrire sur les deux lignes de l’afficheur LCD 2×16 caractères. je vous laisse vous plonger dans les lignes de codes situées ci-dessous

Schéma



Afficheur UsbHid 003

Programme du PIC


program Afficheur_UsbHid_003;
 var
 ReadBuff: array[64] of byte; absolute 0x500;
 WriteBuff: array[64] of byte; absolute 0x500;
 i, i2:byte;
 iValueColomnLcd, iValueColomnLcd2:byte;

ConverCharByte, ConverCharByte2:byte;

 LCD_RS : sbit at RB0_bit;
 LCD_EN : sbit at RB1_bit;
 LCD_D4 : sbit at RB2_bit;
 LCD_D5 : sbit at RB3_bit;
 LCD_D6 : sbit at RB4_bit;
 LCD_D7 : sbit at RB5_bit;
 LCD_RS_Direction : sbit at TRISB0_bit;
 LCD_EN_Direction : sbit at TRISB1_bit;
 LCD_D4_Direction : sbit at TRISB2_bit;
 LCD_D5_Direction : sbit at TRISB3_bit;
 LCD_D6_Direction : sbit at TRISB4_bit;
 LCD_D7_Direction : sbit at TRISB5_bit;
 procedure Main_Init;
   begin
    TRISB:=%00000000;
    LATB:=$00;
    Lcd_Init;
    Lcd_Cmd(_LCD_CURSOR_OFF)
   end;
 procedure Interrupt;
   begin
    USB_Interrupt_Proc;
   end;
 procedure Write_LCD;
   begin
    if (HID_Read()<>0) then

    begin
      for i:=0 to 32 do //On compte de 0 à 32 pour la ligne du haut 
       begin
        if (ReadBuff[i]<>0) then
           begin
             ConverCharByte:=Chr(ReadBuff[i]);
             Lcd_Chr(1,i,ConverCharByte);
             ReadBuff[i]:=0;
           end;

           begin
             if (ReadBuff[i]=1) then
               begin
                 iValueColomnLcd:=0;
                 Lcd_Cmd(_LCD_CLEAR);
               end;
           end;
       end;

   for i2:=32 to 63 do // On compte de 32 à 63 pour la ligne du bas 
      begin
        if (ReadBuff[i2]<>0) then
        begin
         ConverCharByte2:=Chr(ReadBuff[i2]);
         Lcd_Chr(2,(i2-32),ConverCharByte2);
         ReadBuff[i2]:=0;
        end;
      begin
        if (ReadBuff[i2]=1) then
        begin
         iValueColomnLcd2:=0;
         Lcd_Cmd(_LCD_CLEAR);
        end;
      end;
    end;
  end;
 end;
  Begin
   Main_Init;
   HID_Enable(@Readbuff,@WriteBuff);
   While true do
    begin
     Write_LCd;
    end;
  end.

Prototype


Pas de prototype mais le petit fichier qui va avec Afficheur UsbHid 003

Historiques


03/04/16
– Ajout schéma et modification de la console ainsi que la programmation C#
19/03/16
– Première mise à disposition

dernière mise à jour le 13/03/16

Présentation


Le montage électronique présenté ci-dessous, est une amélioration de l’afficheur Afficheur UsbHid 001 qui celui-ci utilise un clavier virtuelle, alors que l’afficheur UsbHid 002 utilise le clavier uniquement. Oui! plus besoin de cliquer sur le clavier virtuelle avec la souris puisque si vous utilisé un clavier c’est encore mieux et plus rapide.

Schéma


Afficheur UsbHid 002

Programmation de l’interface


Driver UsbHid

Programme du PIC


  program Afficheur_UsbHid_002;
  var
  ReadBuff: array[64] of byte; absolute 0x500;
  WriteBuff: array[64] of byte; absolute 0x500;
  i:byte;
  iValueColomnLcd:byte;
  ConverCharByte:byte;
  LCD_RS : sbit at RB0_bit;
  LCD_EN : sbit at RB1_bit;
  LCD_D4 : sbit at RB2_bit;
  LCD_D5 : sbit at RB3_bit;
  LCD_D6 : sbit at RB4_bit;
  LCD_D7 : sbit at RB5_bit;
  LCD_RS_Direction : sbit at TRISB0_bit;
  LCD_EN_Direction : sbit at TRISB1_bit;
  LCD_D4_Direction : sbit at TRISB2_bit;
  LCD_D5_Direction : sbit at TRISB3_bit;
  LCD_D6_Direction : sbit at TRISB4_bit;
  LCD_D7_Direction : sbit at TRISB5_bit;

  procedure Main_Init;
   begin
    TRISB:=%00000000;
    LATB:=$00;
    Lcd_Init;
    Lcd_Cmd(_LCD_CURSOR_OFF)
   end;

  procedure Interrupt;
    begin
     USB_Interrupt_Proc;
    end;

  procedure Write_LCD;
     begin
       if (HID_Read()<>0) then
        begin
         for i:=0 to 63 do
          begin
           if (ReadBuff[i]<>0) then
            begin
             ConverCharByte:=Chr(ReadBuff[i]);
             Lcd_Chr(1,i,ConverCharByte);
             ReadBuff[i]:=0;
            end;
            begin
              if (ReadBuff[i]=1) then
               begin
                iValueColomnLcd:=0;
                Lcd_Cmd(_LCD_CLEAR) ;
               end;
            end;
          end;
        end;
     end;

  Begin
   Main_Init;
   HID_Enable(@Readbuff,@WriteBuff);
   While true do
     begin
      Write_LCd;
     end;
   end.

prototype


Aucun mais le fichier Afficheur UsbHid 002
Non testé sur platine EasyPic mais les résultats donne déjà un bon aperçu.

Proto_1

Historiques


13/03/16
– Première mise à disposition.

Dernière mise à jour le 13/03/16

Présentation


L’Afficheur électronique présenté dans cette article permet via une interface développé en C# sous Visual Studio d’écrire le nom de mon site “DJelectro71.com” sur un écran LCD 2×16 caractères à l’aide d’un clavier virtuelle, vous y trouverez l’exemple dans le prototype un peu plus bas qui a été entierrement développé et testé dans l’environnement MikroPascal sur platine EasyPic 7 . Le but était d’arriver à envoyer une chaine de caractères via le port USB afin que le logiciel du PIC 18F4550 puisse faire tout le travail pour décoder et d’envoyer directement les valeurs reçus sur l’afficheur LCD. Vous pourrez aborder la partie programmation un peu plus bas.

Schéma


Le schéma ci-dessous n’a rien de bien compliquer il suffit de raccorder l’écran LCD 2×16 sur les bonnes broches du PIC 18F4550.

Afficheur UsbHid 001

Programmation de l’interface


Pour que cela fonctionne il faut bien sûr mettre en place le driver disponible sur ce lien usbhiddriver

Programme du PIC


 program Afficheur_UsbHid_001;
  var
  ReadBuff: array[64] of byte; absolute 0x500;
  WriteBuff: array[64] of byte; absolute 0x500;
  i:byte;
  iValueColomnLcd:byte;
  ConverCharByte:byte;
  LCD_RS : sbit at RB0_bit;
  LCD_EN : sbit at RB1_bit;
  LCD_D4 : sbit at RB2_bit;
  LCD_D5 : sbit at RB3_bit;
  LCD_D6 : sbit at RB4_bit;
  LCD_D7 : sbit at RB5_bit;
  LCD_RS_Direction : sbit at TRISB0_bit;
  LCD_EN_Direction : sbit at TRISB1_bit;
  LCD_D4_Direction : sbit at TRISB2_bit;
  LCD_D5_Direction : sbit at TRISB3_bit;
  LCD_D6_Direction : sbit at TRISB4_bit;
  LCD_D7_Direction : sbit at TRISB5_bit;
  procedure Main_Init;
    begin
     TRISB:=%00000000;
     LATB:=$00;
     Lcd_Init;
     Lcd_Cmd(_LCD_CURSOR_OFF)
    end;
  procedure Interrupt;
   begin
   USB_Interrupt_Proc;
   end;
  procedure Write_LCD;
   begin
   if (HID_Read()<>0) then
    begin
    for i:=0 to 63 do
      begin
      if (ReadBuff[i]<>0) then      
         begin
          ConverCharByte:=Chr(readBuff[i]);
          inc(iValueColomnLcd); //incrémente les conlonnes du LCD 
          Lcd_Chr(1,iValueColomnLcd,ConverCharByte); // converti la valeur lue en un caractère 

          begin
           if (ReadBuff[i]=1) then 
            begin
             iValueColomnLcd:=0;
             Lcd_Cmd(_LCD_CLEAR) ; // on efface l'écran LCD
            end;
          end;
        end;
      end;
    end;
  end;
   Begin
    Main_Init;
    HID_Enable(@Readbuff,@WriteBuff);
    While true do
     begin
     Write_LCd;
     end;
   end.

Prototype


Aucun, mais vous pouvez essayer l’interface Afficheur UsbHid 001, à vous de rentrer le programme en MikroPascal dans votre PIC et de créer le Vid/Pid

Proto_1

Juste une petite photo pour le plaisir des yeux…

Historiques


13/03/16
– Première mise à disposition

dernière mise à jour le 12/03/16

Présentation


Le programme proposé ci-dessous permet de déplacer la souris par un simple clic sur le bouton nommé “déplacement”, à vous de changer les valeurs afin que la souris se déplace à un autre endroit.

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Coordonnées_Vectorielles
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int abscisseCurseur = Cursor.Position.X;
            int ordonneeCurseur = Cursor.Position.Y;

            Cursor.Position = new Point(524, 865); //déplacement en X=524 et Y=865  
        }
    }
} 

je vous laisse le fichier (.exe) ici

Historiques


18/01/2019
– mise à jour
12/03/2016
– 1er mise à disposition

Dernière mise à jour le 12/03/16

Présentation


Nous allons nous intéresser sur un programme qui permet de récupérer les coordonnées vectorielles de notre souris. Le programme est développé dans l’environnement C# à l’aide du logiciel Visual Studio.

Programme en C#


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Coordonnées_Vectorielles
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = Convert.ToString("X="+Cursor.Position.X + "  " + "Y="+Cursor.Position.Y);  
        }        
    }
}


Coordonnées X et Y


Chaque fois que nous cliquons dans le rectangle qui correspond à la zone visée nous récupérons les valeurs des coordonnées X et Y de notre souris. Ce principe est intéressant si nous décidons de placer la souris à une endroit précis sur l’écran de l’ordinateur.

Un exemple ici => Coordonnées X et Y

Historiques


18/01/2019
– mise à jour
12/03/2016
– 1er mise à disposition

Dernière mise à jour le 13/03/16

Présentation


Le montage électronique présenté dans cette article, est de pouvoir communiquer entre un ordinateur et le PIC 18F4550 en utilisant la modulation de largeur d’impulsion interne au PIC. L’interface sera programmé en C# à l’aide du logiciel Visual Studio afin de modifier la largeur d’impulsion qui sera envoyé directement au PIC, puis en ce qui concerne la partie programmation du PIC qui traite les données venant de l’interface sera programmé en MikroPascal. L’ensemble de la programmation permettra de faire clignoter une petite led rouge et la luminosité variera en fonction de la largeur d’impulsion (PWM).

Schéma


Contrôleur PWM HIDUSB 001

Alimentation


Régulateur interne


L’alimentation du PIC 18F4550 est faite par l’intermédiaire du port USB de l’ordinateur qui fourni en permanence les 5Vdc. Ensuite  afin d’alimenter le full speed il faut disposer d’une alimentation de 3,3v et pas au dessus!! Nous avons un régulateur interne qui lui génère cette tension il est nommé Vusb alors pourquoi sans priver!!
Ah!! j’allais oublier de vous le dire, il faudra bien penser à activer le régulateur interne dans le logiciel pour qu’il fonctionne.


Vusb

(Clique pour agrandir)


Fonctionnement
Les informations venant du port USB qui sont pilotés par l’interface permettent de contrôler la largeur d’impulsions, puis, cette largeur d’impulsion est réglable via le curseur situé sur l’interface qui lui varie de 0 jusqu’à 10. La capture d’écran ci-dessous montre que le curseur récupère la valeur situé dans le Buffer n°3


Buffer

Programmation de l’interface


Je pense que nous arrivons dans le passage le plus attendu, la programmation de l’interface en C#. Avant d’écrire des lignes et des lignes de codes, il faut avant tout se tourner vers le driver de notre port USB, évidement sans le driver difficile de piloter notre PIC. Je vous laisse le récupérer en cliquant sur le lien usbhiddriver

Programmation C# (Visual Studio)



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;
using USBHIDDRIVER; // à placer dans Visual Studio en c#
namespace Controleur_PWM_UsbHid_001
{
    public partial class Form1 : Form
    {
        USBHIDDRIVER.USBInterface usb = new USBHIDDRIVER.USBInterface("vid_1234", "pid_0001");
        public Form1()
        {
            InitializeComponent();
            usb.enableUsbBufferEvent(new System.EventHandler(myEventCatcher));
         }
        public void myEventCatcher(object sender, System.EventArgs e)
        {
            if (USBHIDDRIVER.USBInterface.usbBuffer.Count > 0)
            {
                byte[] currentRecord = null;
                int counter = 0;
                while ((byte[])USBHIDDRIVER.USBInterface.usbBuffer[counter] == null)
                {
                    lock (USBHIDDRIVER.USBInterface.usbBuffer.SyncRoot)
                    {
                        USBHIDDRIVER.USBInterface.usbBuffer.RemoveAt(0);
                    }
                }
                currentRecord = (byte[])USBHIDDRIVER.USBInterface.usbBuffer[0];
                lock (USBHIDDRIVER.USBInterface.usbBuffer.SyncRoot)
                {
                    USBHIDDRIVER.USBInterface.usbBuffer.RemoveAt(0);
                }
                usb.stopRead();
            }
        }
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            byte[] Buffer = new byte[64];

            int iValueRectify = trackBar1.Value; //on met les valeurs du trackbar1 dans un entier

            byte[] bytesOut = BitConverter.GetBytes(iValueRectify); // converti la valeur rectifiée en Byte

            for (int i = 0; i<9; i++) // la boucle compte jusqu'à 9 cela correspond à 10 bytes (0..9)
            {
                Buffer[i] = Convert.ToByte(iValueRectify); // les 10 sorties sont activées à tours de rôles grâce à l'incrémentation de "i" 
                textBox1.Text = "Buffer["+trackBar1.Value.ToString()+"]"; // on affiche la valeur du trackbar qui correspond au Buffer
            }

            if (usb.write(Buffer)) // écriture dans le Buffer
            {

            }
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

Programme du PIC


Avec un compilateur, il suffit d’écrire ces lignes de codes en MikroPascal et de les compiler dans le PIC 18F4550

program Controleur_PWM_UsbHid_001;

 var
 ReadBuff: array[64] of byte; absolute 0x500;
 WriteBuff: array[64] of byte; absolute 0x500;
 i:byte;

  procedure Main_Init;
   begin
    TRISA:=%00000001;
    TRISB:=%00000000;
    TRISC:=%00000000;
    CMCON:=$07;
    LATA:=$00;
    LATB:=$00;
    ADCON0.ADON:=0; // on désactive la conversion analogique /numérique (A/D)  
    ADCON1.PCFG0:=1; //
    ADCON1.PCFG1:=1; // | Configurations de toutes les entrées
    ADCON1.PCFG2:=1; // | en numérique (D)
    ADCON1.PCFG3:=1; // | ...
    PWM1_Init(1500); // | ...
    PWM1_Start;
  end;

  procedure Interrupt;
   begin
    USB_Interrupt_Proc;
   end;

  procedure Read_PWM;
   begin
    if (HID_Read()<>0) then
     begin
      if (ReadBuff[0]=0) then PWM1_Set_Duty(25);
      if (ReadBuff[1]=1) then PWM1_Set_Duty(50);
      if (ReadBuff[2]=2) then PWM1_Set_Duty(75);
      if (ReadBuff[3]=3) then PWM1_Set_Duty(100);
      if (ReadBuff[4]=4) then PWM1_Set_Duty(125);
      if (ReadBuff[5]=5) then PWM1_Set_Duty(150);
      if (ReadBuff[6]=6) then PWM1_Set_Duty(175);
      if (ReadBuff[7]=7) then PWM1_Set_Duty(200);
      if (ReadBuff[8]=8) then PWM1_Set_Duty(225);
      if (ReadBuff[9]=9) then PWM1_Set_Duty(250);
    end;
  end;

  Begin
   Main_Init;
   HID_Enable(@Readbuff,@WriteBuff);
   for i:=0 to 63 do
     While true do
      begin
       Read_PWM;
     end;
  end. 


Là encore je vous laisser décoder.

Prototype



Proto_1 Proto_2


Proto_3 Proto_4

Historiques


13/03/16
– Attention!! sur le schéma les quartz n’est pas représenté, entre les broches 13 et 14 !!
11/03/2013
– 1er mise à disposition